Fix predictable strategy
In the case where a merge results in an output file that fits in the current level, we will normally just leave it here; but with if said level already has a C-file, then we will not see enough merge steps to actually finish merging in time.
This commit is contained in:
parent
e59c3d7add
commit
166a127a43
1 changed files with 13 additions and 12 deletions
|
@ -546,7 +546,8 @@ main_loop(State = #state{ next=Next }) ->
|
|||
main_loop(State2#state{ a = AFile, c = undefined, merge_pid=undefined })
|
||||
end;
|
||||
|
||||
?CAST(_From,{merge_done, Count, OutFileName}) when Count =< ?BTREE_SIZE(State#state.level) ->
|
||||
?CAST(_From,{merge_done, Count, OutFileName})
|
||||
when Count =< ?BTREE_SIZE(State#state.level), State#state.c =:= undefined ->
|
||||
|
||||
?log("merge_done, out:~w~n -> self", [Count]),
|
||||
|
||||
|
@ -666,17 +667,17 @@ do_step(StepFrom, PreviousWork, StepSize, State) ->
|
|||
%% heuristic doesn't work when there are aggressive deletes (expiry or delete).
|
||||
%% https://github.com/basho/hanoidb/issues/7
|
||||
WorkToDoHere =
|
||||
min(WorkLeftHere, WorkUnitsLeft),
|
||||
%% case hanoidb:get_opt( merge_strategy, State#state.opts, fast) of
|
||||
%% fast ->
|
||||
%% min(WorkLeftHere, WorkUnitsLeft);
|
||||
%% predictable ->
|
||||
%% if (WorkLeftHere < Depth * WorkUnit) ->
|
||||
%% min(WorkLeftHere, WorkUnit);
|
||||
%% true ->
|
||||
%% min(WorkLeftHere, WorkUnitsLeft)
|
||||
%% end
|
||||
%% end,
|
||||
%% min(WorkLeftHere, WorkUnitsLeft),
|
||||
case hanoidb:get_opt( merge_strategy, State#state.opts, fast) of
|
||||
fast ->
|
||||
min(WorkLeftHere, WorkUnitsLeft);
|
||||
predictable ->
|
||||
if (WorkLeftHere < Depth * WorkUnit) ->
|
||||
min(WorkLeftHere, WorkUnit);
|
||||
true ->
|
||||
min(WorkLeftHere, WorkUnitsLeft)
|
||||
end
|
||||
end,
|
||||
WorkIncludingHere = PreviousWork + WorkToDoHere,
|
||||
|
||||
?log("do_step prev:~p, do:~p of ~p ~n", [PreviousWork, WorkToDoHere, WorkLeftHere]),
|
||||
|
|
Loading…
Reference in a new issue