Revert back to slot size of 256

Changing the slot size higher has a significant impact on the fetch
time, although it allows for more constant time on write.  i.e. doubling
the size means 5 x cost of read, if only a 10% increase at write time.
This commit is contained in:
martinsumner 2016-12-23 17:07:05 +00:00
parent b1429a7330
commit 4466210ac8
3 changed files with 12 additions and 34 deletions

View file

@ -38,7 +38,7 @@
-define(SKIP_WIDTH, 16).
-define(LIST_HEIGHT, 2).
-define(SST_WIDTH, 8).
-define(SST_WIDTH, 16).
-define(INFINITY_KEY, {null, null, null, null, null}).
-define(BITARRAY_SIZE, 2048).

View file

@ -9,7 +9,7 @@
-include("include/leveled.hrl").
-define(SLOT_SIZE, 512).
-define(SLOT_SIZE, 256).
-define(COMPRESSION_LEVEL, 1).
-include_lib("eunit/include/eunit.hrl").

View file

@ -73,7 +73,7 @@ check(Key, Bloom) ->
check({hash, Hash}, Bloom).
tiny_empty() ->
<<0:4096>>.
<<0:2048>>.
tiny_enter({hash, no_lookup}, Bloom) ->
Bloom;
@ -81,24 +81,12 @@ tiny_enter({hash, Hash}, Bloom) ->
{Q, Bit0, Bit1, Bit2} = split_hash_for_tinybloom(Hash),
AddFun = fun(Bit, Arr0) -> add_to_array(Bit, Arr0, 1024) end,
case Q of
0 ->
<<Bin1:1024/bitstring, Bin2:3072/bitstring>> = Bloom,
N when N < 2 ->
<<Bin1:1024/bitstring, Bin2:1024/bitstring>> = Bloom,
NewBin = lists:foldl(AddFun, Bin1, [Bit0, Bit1, Bit2]),
<<NewBin/bitstring, Bin2/bitstring>>;
1 ->
<<Bin1:1024/bitstring,
Bin2:1024/bitstring,
Bin3:2048/bitstring>> = Bloom,
NewBin = lists:foldl(AddFun, Bin2, [Bit0, Bit1, Bit2]),
<<Bin1/bitstring, NewBin/bitstring, Bin3/bitstring>>;
2 ->
<<Bin1:2048/bitstring,
Bin2:1024/bitstring,
Bin3:1024/bitstring>> = Bloom,
NewBin = lists:foldl(AddFun, Bin2, [Bit0, Bit1, Bit2]),
<<Bin1/bitstring, NewBin/bitstring, Bin3/bitstring>>;
3 ->
<<Bin1:3072/bitstring, Bin2:1024/bitstring>> = Bloom,
_N ->
<<Bin1:1024/bitstring, Bin2:1024/bitstring>> = Bloom,
NewBin = lists:foldl(AddFun, Bin2, [Bit0, Bit1, Bit2]),
<<Bin1/bitstring, NewBin/bitstring>>
end.
@ -107,21 +95,11 @@ tiny_check({hash, Hash}, FullBloom) ->
{Q, Bit0, Bit1, Bit2} = split_hash_for_tinybloom(Hash),
Bloom =
case Q of
0 ->
<<Bin1:1024/bitstring, _Bin2:3072/bitstring>> = FullBloom,
N when N < 2 ->
<<Bin1:1024/bitstring, _Bin2:1024/bitstring>> = FullBloom,
Bin1;
1 ->
<<_Bin1:1024/bitstring,
Bin2:1024/bitstring,
_Bin3:2048/bitstring>> = FullBloom,
Bin2;
2 ->
<<_Bin1:2048/bitstring,
Bin2:1024/bitstring,
_Bin3:1024/bitstring>> = FullBloom,
Bin2;
3 ->
<<_Bin1:3072/bitstring, Bin2:1024/bitstring>> = FullBloom,
_N ->
<<_Bin1:1024/bitstring, Bin2:1024/bitstring>> = FullBloom,
Bin2
end,
case getbit(Bit0, Bloom, 1024) of
@ -234,7 +212,7 @@ simple_test() ->
?assertMatch(true, FP < (N div 4)).
tiny_test() ->
N = 512,
N = 256,
K = 32, % more checks out then in K * checks
KLin = lists:map(fun(X) -> "Key_" ++
integer_to_list(X) ++