add setting for benchmarking and profiling of sqlite block storage times (#1575)

This commit is contained in:
tersec 2020-08-27 12:52:22 +00:00 committed by Mamy Ratsimbazafy
parent 2aa9f3e17b
commit 0e6619da69
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,7 @@ type Timers = enum
tLoadState = "Load state from database"
tApplyBlock = "Apply block"
tApplyEpochBlock = "Apply epoch block"
tDbStore = "Database block store"
type
DbCmd* = enum
@ -39,6 +40,9 @@ type
slots* {.
defaultValue: 50000
desc: "Number of slots to run benchmark for".}: uint64
storeBlocks* {.
defaultValue: false
desc: "Store each read block back into a separate database".}: bool
of dumpState:
stateRoot* {.
@ -66,6 +70,8 @@ proc cmdBench(conf: DbConf) =
let
db = BeaconChainDB.init(
kvStore SqStoreRef.init(conf.databaseDir.string, "nbc").tryGet())
dbBenchmark = BeaconChainDB.init(
kvStore SqStoreRef.init(".", "benchmark").tryGet())
if not ChainDAGRef.isInitialized(db):
echo "Database not initialized"
@ -109,6 +115,9 @@ proc cmdBench(conf: DbConf) =
dump("./", b)
echo "State transition failed (!)"
quit 1
if conf.storeBlocks:
withTimer(timers[tDbStore]):
dbBenchmark.putBlock(b)
printTimers(false, timers)