mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-21 10:48:17 +00:00
benchmark state loading in ncli_db (#2400)
This commit is contained in:
parent
5ebf36f54d
commit
6533999c82
@ -16,6 +16,7 @@ type Timers = enum
|
|||||||
tAdvanceSlot = "Advance slot, non-epoch"
|
tAdvanceSlot = "Advance slot, non-epoch"
|
||||||
tAdvanceEpoch = "Advance slot, epoch"
|
tAdvanceEpoch = "Advance slot, epoch"
|
||||||
tApplyBlock = "Apply block, no slot processing"
|
tApplyBlock = "Apply block, no slot processing"
|
||||||
|
tDbLoad = "Database load"
|
||||||
tDbStore = "Database store"
|
tDbStore = "Database store"
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -133,7 +134,9 @@ proc cmdBench(conf: DbConf, runtimePreset: RuntimePreset) =
|
|||||||
withTimer(timers[tLoadState]):
|
withTimer(timers[tLoadState]):
|
||||||
discard db.getState(state[].root, state[].data, noRollback)
|
discard db.getState(state[].root, state[].data, noRollback)
|
||||||
|
|
||||||
var cache = StateCache()
|
var
|
||||||
|
cache = StateCache()
|
||||||
|
loadedState = new BeaconState
|
||||||
|
|
||||||
for b in blocks.mitems():
|
for b in blocks.mitems():
|
||||||
while state[].data.slot < b.message.slot:
|
while state[].data.slot < b.message.slot:
|
||||||
@ -157,12 +160,17 @@ proc cmdBench(conf: DbConf, runtimePreset: RuntimePreset) =
|
|||||||
withTimer(timers[tDbStore]):
|
withTimer(timers[tDbStore]):
|
||||||
dbBenchmark.putBlock(b)
|
dbBenchmark.putBlock(b)
|
||||||
|
|
||||||
if conf.storeStates:
|
if conf.storeStates and state[].data.slot.isEpoch:
|
||||||
withTimer(timers[tDbStore]):
|
withTimer(timers[tDbStore]):
|
||||||
if state[].data.slot mod SLOTS_PER_EPOCH == 0:
|
|
||||||
dbBenchmark.putState(state[].root, state[].data)
|
dbBenchmark.putState(state[].root, state[].data)
|
||||||
dbBenchmark.checkpoint()
|
dbBenchmark.checkpoint()
|
||||||
|
|
||||||
|
withTimer(timers[tDbLoad]):
|
||||||
|
doAssert dbBenchmark.getState(state[].root, loadedState[], noRollback)
|
||||||
|
|
||||||
|
if state[].data.slot.epoch mod 16 == 0:
|
||||||
|
doAssert hash_tree_root(state[].data) == hash_tree_root(loadedState[])
|
||||||
|
|
||||||
printTimers(false, timers)
|
printTimers(false, timers)
|
||||||
|
|
||||||
proc cmdDumpState(conf: DbConf, preset: RuntimePreset) =
|
proc cmdDumpState(conf: DbConf, preset: RuntimePreset) =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user