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]) ->
|
||||
SW = os:timestamp(),
|
||||
random:seed(erlang:phash2(self()), element(2, SW), element(3, SW)),
|
||||
case get_opt(snapshot_bookie, Opts) of
|
||||
undefined ->
|
||||
% Start from file not snapshot
|
||||
|
@ -635,7 +637,7 @@ snapshot_store(LedgerCache0, Penciller, Inker, SnapType, Query) ->
|
|||
snapshot_query = Query,
|
||||
bookies_mem = BookiesMem},
|
||||
{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
|
||||
store ->
|
||||
InkerOpts = #inker_options{start_snapshot=true,
|
||||
|
|
|
@ -222,6 +222,8 @@ ink_print_manifest(Pid) ->
|
|||
%%%============================================================================
|
||||
|
||||
init([InkerOpts]) ->
|
||||
SW = os:timestamp(),
|
||||
random:seed(erlang:phash2(self()), element(2, SW), element(3, SW)),
|
||||
case {InkerOpts#inker_options.root_path,
|
||||
InkerOpts#inker_options.start_snapshot} of
|
||||
{undefined, true} ->
|
||||
|
|
|
@ -353,9 +353,7 @@ log_timer(LogReference, Subs, StartTime) ->
|
|||
end.
|
||||
|
||||
log_randomtimer(LogReference, Subs, StartTime, RandomProb) ->
|
||||
{R, _S} = random:uniform_s({erlang:phash2(self()),
|
||||
element(2, StartTime),
|
||||
element(3, StartTime)}),
|
||||
R = random:uniform(),
|
||||
case R < RandomProb of
|
||||
true ->
|
||||
log_timer(LogReference, Subs, StartTime);
|
||||
|
|
|
@ -321,6 +321,8 @@ pcl_doom(Pid) ->
|
|||
%%%============================================================================
|
||||
|
||||
init([PCLopts]) ->
|
||||
SW = os:timestamp(),
|
||||
random:seed(erlang:phash2(self()), element(2, SW), element(3, SW)),
|
||||
case {PCLopts#penciller_options.root_path,
|
||||
PCLopts#penciller_options.start_snapshot,
|
||||
PCLopts#penciller_options.snapshot_query,
|
||||
|
@ -405,7 +407,7 @@ handle_call({fetch_keys, StartKey, EndKey, AccFun, InitAcc, MaxKeys},
|
|||
List ->
|
||||
List
|
||||
end,
|
||||
leveled_log:log_randomtimer("P0037", [length(L0AsList)], SW, 0.1),
|
||||
leveled_log:log_randomtimer("P0037", [length(L0AsList)], SW, 0.01),
|
||||
SetupFoldFun =
|
||||
fun(Level, Acc) ->
|
||||
Pointers = leveled_pmanifest:range_lookup(State#state.manifest,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue