mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-03-03 23:51:22 +00:00
ssz: bump for 10% hash_tree_root perf increase, json loading fix (#5292)
* move file loading out of timed ncli section to focus benchmark on deserialization rather than disk loading * JSON loading fix included in bump, but does not practically happen since we generally don't load hashlist from JSON
This commit is contained in:
parent
255131d331
commit
b39e71335d
@ -96,10 +96,10 @@ template saveSSZFile(filename: string, value: ForkedHashedBeaconState) =
|
||||
of ConsensusFork.Capella: SSZ.saveFile(filename, value.capellaData.data)
|
||||
of ConsensusFork.Deneb: SSZ.saveFile(filename, value.denebData.data)
|
||||
|
||||
proc loadFile(filename: string, T: type): T =
|
||||
proc loadFile(filename: string, bytes: openArray[byte], T: type): T =
|
||||
let
|
||||
ext = splitFile(filename).ext
|
||||
bytes = readAllBytes(filename).expect("file exists")
|
||||
|
||||
if cmpIgnoreCase(ext, ".ssz") == 0:
|
||||
SSZ.decode(bytes, T)
|
||||
elif cmpIgnoreCase(ext, ".ssz_snappy") == 0:
|
||||
@ -187,11 +187,12 @@ proc doSSZ(conf: NcliConf) =
|
||||
of pretty: (conf.prettyKind, conf.prettyFile)
|
||||
else:
|
||||
raiseAssert "doSSZ() only implements hashTreeRoot and pretty commands"
|
||||
let bytes = readAllBytes(file).expect("file exists")
|
||||
|
||||
template printit(t: untyped) {.dirty.} =
|
||||
|
||||
let v = withTimerRet(timers[tLoad]):
|
||||
newClone(loadFile(file, t))
|
||||
newClone(loadFile(file, bytes, t))
|
||||
|
||||
case conf.cmd:
|
||||
of hashTreeRoot:
|
||||
|
2
vendor/nim-ssz-serialization
vendored
2
vendor/nim-ssz-serialization
vendored
@ -1 +1 @@
|
||||
Subproject commit c6aa85e1f59076eeabafa607ab8489f95fdbba20
|
||||
Subproject commit 3b1f866e419527fdd4b36d054e94678c3035b879
|
Loading…
x
Reference in New Issue
Block a user