Add GC are initialisation

in OTP R16 (and perhaps other OTP releases) there is a failure to fully garbage collect leveled_sst files after thya have initialised.  They sppear to maintain a 4MB "hangover" from the initialisation process.

This can be removed by manually calling garbage_collect.  So we do this now on all new non-L0 files.  A L0 file will be short-lived or switched - short-lived and it doesn't matter, switched and this is already GC'd.
This commit is contained in:
Martin Sumner 2019-03-28 13:23:37 +00:00
parent 1c5bc3f6d3
commit 42c4100c2d

View file

@ -512,12 +512,14 @@ starting({sst_new,
leveled_log:log_timer("SST08",
[ActualFilename, Level, Summary#summary.max_sqn],
SW),
erlang:send_after(?STARTUP_TIMEOUT, self(), timeout),
% always want to have an opportunity to GC - so force the timeout to
% occur whether or not there is an intervening message
{reply,
{ok, {Summary#summary.first_key, Summary#summary.last_key}, Bloom},
reader,
UpdState#state{blockindex_cache = BlockIndex,
starting_pid = StartingPID},
?STARTUP_TIMEOUT};
starting_pid = StartingPID}};
starting({sst_newlevelzero, RootPath, Filename,
Penciller, MaxSQN,
OptsSST, IdxModDate}, _From, State) ->
@ -715,6 +717,7 @@ reader(switch_levels, State) ->
reader(timeout, State) ->
case is_process_alive(State#state.starting_pid) of
true ->
erlang:garbage_collect(self()),
{next_state, reader, State};
false ->
{stop, normal, State}