nimbus-eth2/nbench/nbench.nim
Mamy Ratsimbazafy 106352aff3
Nbench - Flexible benchmarking of Nimbus internals (#641)
* nbench PoC

* Remove the yaml files from the example scenarios

* update README with current status

* Add an alternative implementation that uses defer

* Forgot to add the old proc body

* slots-processing

* allow benching state_transition failures

* Add Attestations processing (workaround confutils bug:
- https://github.com/status-im/nim-confutils/issues/10
- https://github.com/status-im/nim-confutils/issues/11
- https://github.com/status-im/nim-confutils/issues/12

* Add CLI command in the readme

* Filter report and add notes about CPU cycles

* Report averages

* Add debugecho style time/cycle print

* Report when we skip BLS and state root verification

* Update to 0.9.3

* Generalize scenario parsing

* Support all block processing scenarios

* parallel bench runner PoC

* gitBetter load issues reporting (the load issues were invalid signature and expected to fail)
2019-12-20 17:14:43 +01:00

112 lines
3.4 KiB
Nim

# beacon_chain
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import
# Standard library
os,
# Status libraries
confutils, serialization,
# Beacon-chain
../beacon_chain/spec/datatypes,
# Bench specific
scenarios, bench_lab, reports
# Example:
# build/nbench cmdFullStateTransition -d
# Nimbus Bench
# --------------------------------------------------
#
# Run select scenarios and get statistics on Nimbus runtime behaviour
when not defined(nbench):
{.error: "`nbench` requires `-d:nbench` flag to enable tracing on procedures.".}
proc main() =
# TODO versioning
echo "Nimbus bench, preset \"", const_preset, '\"'
BenchMetrics = static(ctBenchMetrics) # Make compile-time data available at runtime
let scenario = ScenarioConf.load()
case scenario.cmd
of cmdFullStateTransition:
runFullTransition(
scenario.scenarioDir.string,
scenario.preState,
scenario.blocksPrefix,
scenario.blocksQty,
scenario.skipBLS
)
of cmdSlotProcessing:
runProcessSlots(
scenario.scenarioDir.string,
scenario.preState,
scenario.numSlots
)
of cmdBlockProcessing:
case scenario.blockProcessingCat
of catBlockHeader:
runProcessBlockHeader(
scenario.scenarioDir.string,
scenario.preState,
"block", # Pending https://github.com/status-im/nim-confutils/issues/11
# scenario.attesterSlashing
scenario.skipBLS
)
of catProposerSlashings:
runProcessProposerSlashing(
scenario.scenarioDir.string,
scenario.preState,
"proposer_slashing", # Pending https://github.com/status-im/nim-confutils/issues/11
# scenario.attesterSlashing
scenario.skipBLS
)
of catAttesterSlashings:
runProcessAttesterSlashing(
scenario.scenarioDir.string,
scenario.preState,
"attester_slashing" # Pending https://github.com/status-im/nim-confutils/issues/11
# scenario.attesterSlashing
)
of catAttestations:
runProcessAttestation(
scenario.scenarioDir.string,
scenario.preState,
"attestation", # Pending https://github.com/status-im/nim-confutils/issues/11
# scenario.attestation,
scenario.skipBLS
)
of catDeposits:
runProcessDeposit(
scenario.scenarioDir.string,
scenario.preState,
"deposit", # Pending https://github.com/status-im/nim-confutils/issues/11
# scenario.deposit,
scenario.skipBLS
)
of catVoluntaryExits:
runProcessVoluntaryExits(
scenario.scenarioDir.string,
scenario.preState,
"voluntary_exit", # Pending https://github.com/status-im/nim-confutils/issues/11
# scenario.voluntary_exit,
scenario.skipBLS
)
else:
quit "Unsupported"
else:
quit "Unsupported"
# TODO: Nimbus not fine-grained enough in UpdateFlags
let flags = if scenario.skipBLS: "[skipBLS, skipStateRootVerification]"
else: "[withBLS, withStateRootVerification]"
reportCli(BenchMetrics, const_preset, flags)
when isMainModule:
main()