Seed randomnes at Actor startup
This commit is contained in:
parent
32cdf26ffb
commit
9ad6969b0d
4 changed files with 9 additions and 5 deletions
|
@ -358,6 +358,8 @@ book_destroy(Pid) ->
|
||||||
%%%============================================================================
|
%%%============================================================================
|
||||||
|
|
||||||
init([Opts]) ->
|
init([Opts]) ->
|
||||||
|
SW = os:timestamp(),
|
||||||
|
random:seed(erlang:phash2(self()), element(2, SW), element(3, SW)),
|
||||||
case get_opt(snapshot_bookie, Opts) of
|
case get_opt(snapshot_bookie, Opts) of
|
||||||
undefined ->
|
undefined ->
|
||||||
% Start from file not snapshot
|
% Start from file not snapshot
|
||||||
|
@ -635,7 +637,7 @@ snapshot_store(LedgerCache0, Penciller, Inker, SnapType, Query) ->
|
||||||
snapshot_query = Query,
|
snapshot_query = Query,
|
||||||
bookies_mem = BookiesMem},
|
bookies_mem = BookiesMem},
|
||||||
{ok, LedgerSnapshot} = leveled_penciller:pcl_start(PCLopts),
|
{ok, LedgerSnapshot} = leveled_penciller:pcl_start(PCLopts),
|
||||||
leveled_log:log_randomtimer("B0004", [cache_size(LedgerCache)], SW, 0.1),
|
leveled_log:log_randomtimer("B0004", [cache_size(LedgerCache)], SW, 0.02),
|
||||||
case SnapType of
|
case SnapType of
|
||||||
store ->
|
store ->
|
||||||
InkerOpts = #inker_options{start_snapshot=true,
|
InkerOpts = #inker_options{start_snapshot=true,
|
||||||
|
|
|
@ -222,6 +222,8 @@ ink_print_manifest(Pid) ->
|
||||||
%%%============================================================================
|
%%%============================================================================
|
||||||
|
|
||||||
init([InkerOpts]) ->
|
init([InkerOpts]) ->
|
||||||
|
SW = os:timestamp(),
|
||||||
|
random:seed(erlang:phash2(self()), element(2, SW), element(3, SW)),
|
||||||
case {InkerOpts#inker_options.root_path,
|
case {InkerOpts#inker_options.root_path,
|
||||||
InkerOpts#inker_options.start_snapshot} of
|
InkerOpts#inker_options.start_snapshot} of
|
||||||
{undefined, true} ->
|
{undefined, true} ->
|
||||||
|
|
|
@ -353,9 +353,7 @@ log_timer(LogReference, Subs, StartTime) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
log_randomtimer(LogReference, Subs, StartTime, RandomProb) ->
|
log_randomtimer(LogReference, Subs, StartTime, RandomProb) ->
|
||||||
{R, _S} = random:uniform_s({erlang:phash2(self()),
|
R = random:uniform(),
|
||||||
element(2, StartTime),
|
|
||||||
element(3, StartTime)}),
|
|
||||||
case R < RandomProb of
|
case R < RandomProb of
|
||||||
true ->
|
true ->
|
||||||
log_timer(LogReference, Subs, StartTime);
|
log_timer(LogReference, Subs, StartTime);
|
||||||
|
|
|
@ -321,6 +321,8 @@ pcl_doom(Pid) ->
|
||||||
%%%============================================================================
|
%%%============================================================================
|
||||||
|
|
||||||
init([PCLopts]) ->
|
init([PCLopts]) ->
|
||||||
|
SW = os:timestamp(),
|
||||||
|
random:seed(erlang:phash2(self()), element(2, SW), element(3, SW)),
|
||||||
case {PCLopts#penciller_options.root_path,
|
case {PCLopts#penciller_options.root_path,
|
||||||
PCLopts#penciller_options.start_snapshot,
|
PCLopts#penciller_options.start_snapshot,
|
||||||
PCLopts#penciller_options.snapshot_query,
|
PCLopts#penciller_options.snapshot_query,
|
||||||
|
@ -405,7 +407,7 @@ handle_call({fetch_keys, StartKey, EndKey, AccFun, InitAcc, MaxKeys},
|
||||||
List ->
|
List ->
|
||||||
List
|
List
|
||||||
end,
|
end,
|
||||||
leveled_log:log_randomtimer("P0037", [length(L0AsList)], SW, 0.1),
|
leveled_log:log_randomtimer("P0037", [length(L0AsList)], SW, 0.01),
|
||||||
SetupFoldFun =
|
SetupFoldFun =
|
||||||
fun(Level, Acc) ->
|
fun(Level, Acc) ->
|
||||||
Pointers = leveled_pmanifest:range_lookup(State#state.manifest,
|
Pointers = leveled_pmanifest:range_lookup(State#state.manifest,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue