From f0833de3fca5c0920874cb424587726216c9ca7a Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Sun, 29 Apr 2012 00:33:15 +0200 Subject: [PATCH] Set default pagesize to 8k Also reduce read ahead / delayed write parameters so we don't need too much memory in merge procs. --- README.md | 2 +- src/hanoi_reader.erl | 2 +- src/hanoi_writer.erl | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 96c8c75..30ca849 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Put these values in your `app.config` in the `hanoi` section {data_root, "./data/hanoi"}, {compress, none | snappy | gzip}, {sync_strategy, none | sync | {seconds, N}}, - {page_size, 32768} + {page_size, 8192} ]}, ``` diff --git a/src/hanoi_reader.erl b/src/hanoi_reader.erl index 1ab863f..c72133c 100644 --- a/src/hanoi_reader.erl +++ b/src/hanoi_reader.erl @@ -46,7 +46,7 @@ open(Name) -> %% this is how to open a btree for sequential scanning (merge, fold) open(Name, sequential) -> - {ok, File} = file:open(Name, [raw,read,{read_ahead, 1024 * 512},binary]), + {ok, File} = file:open(Name, [raw,read,{read_ahead, 1024 * 32},binary]), open2(Name, File); %% this is how to open a btree for random access diff --git a/src/hanoi_writer.erl b/src/hanoi_writer.erl index aa84f77..1584c21 100644 --- a/src/hanoi_writer.erl +++ b/src/hanoi_writer.erl @@ -31,7 +31,7 @@ %% Streaming btree writer. Accepts only monotonically increasing keys for put. %% --define(NODE_SIZE, 32*1024). +-define(NODE_SIZE, 8*1024). -behavior(gen_server). @@ -82,15 +82,15 @@ init([Name,Options]) -> Size = proplists:get_value(size, Options, 2048), % io:format("got name: ~p~n", [Name]), - + BlockSize = hanoi:get_opt(block_size, Options, ?NODE_SIZE), case file:open( hanoi_util:index_file_name(Name), - [raw, exclusive, write, {delayed_write, 512 * 1024, 2000}]) of + [raw, exclusive, write, {delayed_write, BlockSize * 4, 2000}]) of {ok, IdxFile} -> {ok, BloomFilter} = ebloom:new(erlang:min(Size,16#ffffffff), 0.01, 123), {ok, #state{ name=Name, index_file_pos=0, index_file=IdxFile, bloom = BloomFilter, - block_size = hanoi:get_opt(block_size, Options, ?NODE_SIZE), + block_size = BlockSize, compress = hanoi:get_opt(compress, Options, none) }}; {error, _}=Error ->