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 GitHub
parent c810b64ed8
commit b8da265f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)