Rationalise logging on push_mem

This commit is contained in:
martinsumner 2016-11-05 13:42:44 +00:00
parent 9e410d65e3
commit 4556573a5c
2 changed files with 24 additions and 32 deletions

View file

@ -35,8 +35,6 @@
{"P0001", {"P0001",
{info, "Ledger snapshot ~w registered"}}, {info, "Ledger snapshot ~w registered"}},
{"P0002",
{info, "Handling of push completed with L0 cache size now ~w"}},
{"P0003", {"P0003",
{info, "Ledger snapshot ~w released"}}, {info, "Ledger snapshot ~w released"}},
{"P0004", {"P0004",

View file

@ -376,23 +376,20 @@ handle_call({push_mem, PushedTree}, From, State=#state{is_snapshot=Snap})
% %
% Check the approximate size of the cache. If it is over the maximum size, % Check the approximate size of the cache. If it is over the maximum size,
% trigger a backgroun L0 file write and update state of levelzero_pending. % trigger a backgroun L0 file write and update state of levelzero_pending.
case State#state.levelzero_pending of
SW = os:timestamp(), true ->
S = case State#state.levelzero_pending of leveled_log:log("P0018", [returned, "L-0 persist pending"]),
true -> {reply, returned, State};
log_pushmem_reply(From, {returned, "L-0 persist pending"}, SW), false ->
State; leveled_log:log("P0018", [ok, "L0 memory updated"]),
false -> gen_server:reply(From, ok),
log_pushmem_reply(From, {ok, "L0 memory updated"}, SW), {noreply, update_levelzero(State#state.levelzero_index,
update_levelzero(State#state.levelzero_index, State#state.levelzero_size,
State#state.levelzero_size, PushedTree,
PushedTree, State#state.ledger_sqn,
State#state.ledger_sqn, State#state.levelzero_cache,
State#state.levelzero_cache, State)}
State) end;
end,
leveled_log:log_timer("P0002", [S#state.levelzero_size], SW),
{noreply, S};
handle_call({fetch, Key}, _From, State) -> handle_call({fetch, Key}, _From, State) ->
{reply, {reply,
fetch_mem(Key, fetch_mem(Key,
@ -648,10 +645,6 @@ start_from_file(PCLopts) ->
end. end.
log_pushmem_reply(From, Reply, SW) ->
leveled_log:log_timer("P0018", [element(1,Reply), element(2,Reply)], SW),
gen_server:reply(From, element(1, Reply)).
update_levelzero(L0Index, L0Size, PushedTree, LedgerSQN, L0Cache, State) -> update_levelzero(L0Index, L0Size, PushedTree, LedgerSQN, L0Cache, State) ->
Update = leveled_pmem:add_to_index(L0Index, Update = leveled_pmem:add_to_index(L0Index,
@ -684,15 +677,6 @@ update_levelzero(L0Index, L0Size, PushedTree, LedgerSQN, L0Cache, State) ->
end. end.
checkready(Pid) ->
try
leveled_sft:sft_checkready(Pid)
catch
exit:{timeout, _} ->
timeout
end.
%% Casting a large object (the levelzero cache) to the gen_server did not lead %% Casting a large object (the levelzero cache) to the gen_server did not lead
%% to an immediate return as expected. With 32K keys in the TreeList it could %% to an immediate return as expected. With 32K keys in the TreeList it could
%% take around 35-40ms. %% take around 35-40ms.
@ -1661,4 +1645,14 @@ coverage_test() ->
ok = pcl_close(PCLr), ok = pcl_close(PCLr),
clean_testdir(RootPath). clean_testdir(RootPath).
checkready(Pid) ->
try
leveled_sft:sft_checkready(Pid)
catch
exit:{timeout, _} ->
timeout
end.
-endif. -endif.