Change page cache loading by lookup/no_lookup
By default load the first 4 levels of the ledger into the page cache of lookup is to be supported, but just levels 0 and 1 otherwise.
This commit is contained in:
parent
85bfa7fbb4
commit
7862a6c523
3 changed files with 33 additions and 13 deletions
|
@ -51,7 +51,8 @@
|
||||||
:: leveled_sst:press_method(),
|
:: leveled_sst:press_method(),
|
||||||
log_options = leveled_log:get_opts()
|
log_options = leveled_log:get_opts()
|
||||||
:: leveled_log:log_options(),
|
:: leveled_log:log_options(),
|
||||||
max_sstslots = 256 :: pos_integer()}).
|
max_sstslots = 256 :: pos_integer(),
|
||||||
|
pagecache_level = 1 :: pos_integer()}).
|
||||||
|
|
||||||
-record(inker_options,
|
-record(inker_options,
|
||||||
{cdb_max_size :: integer() | undefined,
|
{cdb_max_size :: integer() | undefined,
|
||||||
|
|
|
@ -127,6 +127,8 @@
|
||||||
-define(OPEN_LASTMOD_RANGE, {0, infinity}).
|
-define(OPEN_LASTMOD_RANGE, {0, infinity}).
|
||||||
-define(SNAPTIMEOUT_SHORT, 900). % 15 minutes
|
-define(SNAPTIMEOUT_SHORT, 900). % 15 minutes
|
||||||
-define(SNAPTIMEOUT_LONG, 43200). % 12 hours
|
-define(SNAPTIMEOUT_LONG, 43200). % 12 hours
|
||||||
|
-define(SST_PAGECACHELEVEL_NOLOOKUP, 1).
|
||||||
|
-define(SST_PAGECACHELEVEL_LOOKUP, 4).
|
||||||
-define(OPTION_DEFAULTS,
|
-define(OPTION_DEFAULTS,
|
||||||
[{root_path, undefined},
|
[{root_path, undefined},
|
||||||
{snapshot_bookie, undefined},
|
{snapshot_bookie, undefined},
|
||||||
|
@ -1177,15 +1179,22 @@ init([Opts]) ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
|
||||||
{HeadOnly, HeadLookup} =
|
{HeadOnly, HeadLookup, SSTPageCacheLevel} =
|
||||||
case proplists:get_value(head_only, Opts) of
|
case proplists:get_value(head_only, Opts) of
|
||||||
false ->
|
false ->
|
||||||
{false, true};
|
{false, true, ?SST_PAGECACHELEVEL_LOOKUP};
|
||||||
with_lookup ->
|
with_lookup ->
|
||||||
{true, true};
|
{true, true, ?SST_PAGECACHELEVEL_LOOKUP};
|
||||||
no_lookup ->
|
no_lookup ->
|
||||||
{true, false}
|
{true, false, ?SST_PAGECACHELEVEL_NOLOOKUP}
|
||||||
end,
|
end,
|
||||||
|
% Override the default page cache level - we want to load into the
|
||||||
|
% page cache many levels if we intend to support lookups, and only
|
||||||
|
% levels 0 and 1 otherwise
|
||||||
|
SSTOpts = PencillerOpts#penciller_options.sst_options,
|
||||||
|
SSTOpts0 = SSTOpts#sst_options{pagecache_level = SSTPageCacheLevel},
|
||||||
|
PencillerOpts0 =
|
||||||
|
PencillerOpts#penciller_options{sst_options = SSTOpts0},
|
||||||
|
|
||||||
State0 = #state{cache_size=CacheSize,
|
State0 = #state{cache_size=CacheSize,
|
||||||
is_snapshot=false,
|
is_snapshot=false,
|
||||||
|
@ -1193,7 +1202,7 @@ init([Opts]) ->
|
||||||
head_lookup = HeadLookup},
|
head_lookup = HeadLookup},
|
||||||
|
|
||||||
{Inker, Penciller} =
|
{Inker, Penciller} =
|
||||||
startup(InkerOpts, PencillerOpts, State0),
|
startup(InkerOpts, PencillerOpts0, State0),
|
||||||
|
|
||||||
NewETS = ets:new(mem, [ordered_set]),
|
NewETS = ets:new(mem, [ordered_set]),
|
||||||
leveled_log:log("B0001", [Inker, Penciller]),
|
leveled_log:log("B0001", [Inker, Penciller]),
|
||||||
|
|
|
@ -486,7 +486,9 @@ init([]) ->
|
||||||
starting({sst_open, RootPath, Filename, OptsSST, Level}, _From, State) ->
|
starting({sst_open, RootPath, Filename, OptsSST, Level}, _From, State) ->
|
||||||
leveled_log:save(OptsSST#sst_options.log_options),
|
leveled_log:save(OptsSST#sst_options.log_options),
|
||||||
{UpdState, Bloom} =
|
{UpdState, Bloom} =
|
||||||
read_file(Filename, State#state{root_path=RootPath}),
|
read_file(Filename,
|
||||||
|
State#state{root_path=RootPath},
|
||||||
|
OptsSST#sst_options.pagecache_level >= Level),
|
||||||
Summary = UpdState#state.summary,
|
Summary = UpdState#state.summary,
|
||||||
{reply,
|
{reply,
|
||||||
{ok, {Summary#summary.first_key, Summary#summary.last_key}, Bloom},
|
{ok, {Summary#summary.first_key, Summary#summary.last_key}, Bloom},
|
||||||
|
@ -509,7 +511,8 @@ starting({sst_new,
|
||||||
YBQ = Level =< 2,
|
YBQ = Level =< 2,
|
||||||
{UpdState, Bloom} =
|
{UpdState, Bloom} =
|
||||||
read_file(ActualFilename,
|
read_file(ActualFilename,
|
||||||
State#state{root_path=RootPath, yield_blockquery=YBQ}),
|
State#state{root_path=RootPath, yield_blockquery=YBQ},
|
||||||
|
OptsSST#sst_options.pagecache_level >= Level),
|
||||||
Summary = UpdState#state.summary,
|
Summary = UpdState#state.summary,
|
||||||
leveled_log:log_timer("SST08",
|
leveled_log:log_timer("SST08",
|
||||||
[ActualFilename, Level, Summary#summary.max_sqn],
|
[ActualFilename, Level, Summary#summary.max_sqn],
|
||||||
|
@ -573,7 +576,8 @@ starting(complete_l0startup, State) ->
|
||||||
% Important to empty this from state rather
|
% Important to empty this from state rather
|
||||||
% than carry it through to the next stage
|
% than carry it through to the next stage
|
||||||
new_slots=undefined,
|
new_slots=undefined,
|
||||||
deferred_startup_tuple=undefined}),
|
deferred_startup_tuple=undefined},
|
||||||
|
true),
|
||||||
Summary = UpdState#state.summary,
|
Summary = UpdState#state.summary,
|
||||||
Time4 = timer:now_diff(os:timestamp(), SW4),
|
Time4 = timer:now_diff(os:timestamp(), SW4),
|
||||||
|
|
||||||
|
@ -1215,9 +1219,10 @@ write_file(RootPath, Filename, SummaryBin, SlotsBin,
|
||||||
filename:join(RootPath, FinalName)),
|
filename:join(RootPath, FinalName)),
|
||||||
FinalName.
|
FinalName.
|
||||||
|
|
||||||
read_file(Filename, State) ->
|
read_file(Filename, State, LoadPageCache) ->
|
||||||
{Handle, FileVersion, SummaryBin} =
|
{Handle, FileVersion, SummaryBin} =
|
||||||
open_reader(filename:join(State#state.root_path, Filename)),
|
open_reader(filename:join(State#state.root_path, Filename),
|
||||||
|
LoadPageCache),
|
||||||
UpdState0 = imp_fileversion(FileVersion, State),
|
UpdState0 = imp_fileversion(FileVersion, State),
|
||||||
{Summary, Bloom, SlotList} = read_table_summary(SummaryBin),
|
{Summary, Bloom, SlotList} = read_table_summary(SummaryBin),
|
||||||
BlockIndexCache = array:new([{size, Summary#summary.size},
|
BlockIndexCache = array:new([{size, Summary#summary.size},
|
||||||
|
@ -1269,13 +1274,18 @@ imp_fileversion(VersionInt, State) ->
|
||||||
end,
|
end,
|
||||||
UpdState1.
|
UpdState1.
|
||||||
|
|
||||||
open_reader(Filename) ->
|
open_reader(Filename, LoadPageCache) ->
|
||||||
{ok, Handle} = file:open(Filename, [binary, raw, read]),
|
{ok, Handle} = file:open(Filename, [binary, raw, read]),
|
||||||
{ok, Lengths} = file:pread(Handle, 0, 9),
|
{ok, Lengths} = file:pread(Handle, 0, 9),
|
||||||
<<FileVersion:8/integer,
|
<<FileVersion:8/integer,
|
||||||
SlotsLength:32/integer,
|
SlotsLength:32/integer,
|
||||||
SummaryLength:32/integer>> = Lengths,
|
SummaryLength:32/integer>> = Lengths,
|
||||||
ok = file:advise(Handle, 9, SlotsLength, will_need),
|
case LoadPageCache of
|
||||||
|
true ->
|
||||||
|
file:advise(Handle, 9, SlotsLength, will_need);
|
||||||
|
false ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
{ok, SummaryBin} = file:pread(Handle, SlotsLength + 9, SummaryLength),
|
{ok, SummaryBin} = file:pread(Handle, SlotsLength + 9, SummaryLength),
|
||||||
{Handle, FileVersion, SummaryBin}.
|
{Handle, FileVersion, SummaryBin}.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue