Skip to content
Browse files

Merge branch 'slf-bump-reductions' into gh41-quviq-pulse-and-qc-slf-b…

…ugfixes
  • Loading branch information...
2 parents 6e58a37 + 756f4b1 commit d7c2f5c048876b7f00e4e798d07f09157fac49b0 @slfritchie slfritchie committed Nov 15, 2012
Showing with 103 additions and 25 deletions.
  1. +13 −13 c_src/bitcask_nifs.c
  2. +30 −0 src/bitcask_bump.erl
  3. +60 −12 src/bitcask_nifs.erl
View
26 c_src/bitcask_nifs.c
@@ -245,19 +245,19 @@ static ErlNifFunc nif_funcs[] =
{"keydir_info", 1, bitcask_nifs_keydir_info},
{"keydir_release", 1, bitcask_nifs_keydir_release},
- {"lock_acquire", 2, bitcask_nifs_lock_acquire},
- {"lock_release", 1, bitcask_nifs_lock_release},
- {"lock_readdata", 1, bitcask_nifs_lock_readdata},
- {"lock_writedata", 2, bitcask_nifs_lock_writedata},
-
- {"file_open", 2, bitcask_nifs_file_open},
- {"file_close", 1, bitcask_nifs_file_close},
- {"file_sync", 1, bitcask_nifs_file_sync},
- {"file_pread", 3, bitcask_nifs_file_pread},
- {"file_pwrite", 3, bitcask_nifs_file_pwrite},
- {"file_read", 2, bitcask_nifs_file_read},
- {"file_write", 2, bitcask_nifs_file_write},
- {"file_seekbof", 1, bitcask_nifs_file_seekbof}
+ {"lock_acquire_int", 2, bitcask_nifs_lock_acquire},
+ {"lock_release_int", 1, bitcask_nifs_lock_release},
+ {"lock_readdata_int", 1, bitcask_nifs_lock_readdata},
+ {"lock_writedata_int", 2, bitcask_nifs_lock_writedata},
+
+ {"file_open_int", 2, bitcask_nifs_file_open},
+ {"file_close_int", 1, bitcask_nifs_file_close},
+ {"file_sync_int", 1, bitcask_nifs_file_sync},
+ {"file_pread_int", 3, bitcask_nifs_file_pread},
+ {"file_pwrite_int", 3, bitcask_nifs_file_pwrite},
+ {"file_read_int", 2, bitcask_nifs_file_read},
+ {"file_write_int", 2, bitcask_nifs_file_write},
+ {"file_seekbof_int", 1, bitcask_nifs_file_seekbof}
};
ERL_NIF_TERM bitcask_nifs_keydir_new0(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
View
30 src/bitcask_bump.erl
@@ -0,0 +1,30 @@
+%% -------------------------------------------------------------------
+%%
+%% bitcask: Eric Brewer-inspired key/value store
+%%
+%% Copyright (c) 2012 Basho Technologies, Inc. All Rights Reserved.
+%%
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+%%
+%% http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+%% -------------------------------------------------------------------
+-module(bitcask_bump).
+
+-export([big/0, small/0]).
+
+big() ->
+ erlang:bump_reductions(1900).
+
+small() ->
+ erlang:bump_reductions(500).
View
72 src/bitcask_nifs.erl
@@ -332,7 +332,11 @@ keydir_release(_Ref) ->
end.
-lock_acquire(_Filename, _IsWriteLock) ->
+lock_acquire(Filename, IsWriteLock) ->
+ bitcask_bump:big(),
+ lock_acquire_int(Filename, IsWriteLock).
+
+lock_acquire_int(_Filename, _IsWriteLock) ->
case random:uniform(999999999999) of
666 -> {ok, make_ref()};
667 -> {error, enoent};
@@ -341,13 +345,21 @@ lock_acquire(_Filename, _IsWriteLock) ->
_ -> exit("NIF library not loaded")
end.
-lock_release(_Ref) ->
+lock_release(Ref) ->
+ bitcask_bump:big(),
+ lock_release_int(Ref).
+
+lock_release_int(_Ref) ->
case random:uniform(999999999999) of
666 -> ok;
_ -> exit("NIF library not loaded")
end.
-lock_readdata(_Ref) ->
+lock_readdata(Ref) ->
+ bitcask_bump:big(),
+ lock_readdata_int(Ref).
+
+lock_readdata_int(_Ref) ->
case random:uniform(999999999999) of
666 -> {fstat_error, random:uniform(4242)};
667 -> {error, allocation_error};
@@ -356,7 +368,11 @@ lock_readdata(_Ref) ->
_ -> exit("NIF library not loaded")
end.
-lock_writedata(_Ref, _Data) ->
+lock_writedata(Ref, Data) ->
+ bitcask_bump:big(),
+ lock_writedata_int(Ref, Data).
+
+lock_writedata_int(_Ref, _Data) ->
case random:uniform(999999999999) of
666 -> {ftruncate_error, random:uniform(4242)};
667 -> {pwrite_error, random:uniform(4242)};
@@ -365,28 +381,60 @@ lock_writedata(_Ref, _Data) ->
_ -> exit("NIF library not loaded")
end.
-file_open(_Filename, _Opts) ->
+file_open(Filename, Opts) ->
+ bitcask_bump:big(),
+ file_open_int(Filename, Opts).
+
+file_open_int(_Filename, _Opts) ->
erlang:nif_error({error, not_loaded}).
-file_close(_Ref) ->
+file_close(Ref) ->
+ bitcask_bump:big(),
+ file_close_int(Ref).
+
+file_close_int(_Ref) ->
erlang:nif_error({error, not_loaded}).
-file_sync(_Ref) ->
+file_sync(Ref) ->
+ bitcask_bump:big(),
+ file_sync_int(Ref).
+
+file_sync_int(_Ref) ->
erlang:nif_error({error, not_loaded}).
-file_pread(_Ref, _Offset, _Size) ->
+file_pread(Ref, Offset, Size) ->
+ bitcask_bump:big(),
+ file_pread_int(Ref, Offset, Size).
+
+file_pread_int(_Ref, _Offset, _Size) ->
erlang:nif_error({error, not_loaded}).
-file_pwrite(_Ref, _Offset, _Bytes) ->
+file_pwrite(Ref, Offset, Bytes) ->
+ bitcask_bump:big(),
+ file_pwrite_int(Ref, Offset, Bytes).
+
+file_pwrite_int(_Ref, _Offset, _Bytes) ->
erlang:nif_error({error, not_loaded}).
-file_read(_Ref, _Size) ->
+file_read(Ref, Size) ->
+ bitcask_bump:big(),
+ file_read_int(Ref, Size).
+
+file_read_int(_Ref, _Size) ->
erlang:nif_error({error, not_loaded}).
-file_write(_Ref, _Bytes) ->
+file_write(Ref, Bytes) ->
+ bitcask_bump:big(),
+ file_write_int(Ref, Bytes).
+
+file_write_int(_Ref, _Bytes) ->
erlang:nif_error({error, not_loaded}).
-file_seekbof(_Ref) ->
+file_seekbof(Ref) ->
+ bitcask_bump:big(),
+ file_seekbof_int(Ref).
+
+file_seekbof_int(_Ref) ->
erlang:nif_error({error, not_loaded}).

0 comments on commit d7c2f5c

Please sign in to comment.
Something went wrong with that request. Please try again.