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.Capella: SSZ.saveFile(filename, value.capellaData.data)
|
||||||
of ConsensusFork.Deneb: SSZ.saveFile(filename, value.denebData.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
|
let
|
||||||
ext = splitFile(filename).ext
|
ext = splitFile(filename).ext
|
||||||
bytes = readAllBytes(filename).expect("file exists")
|
|
||||||
if cmpIgnoreCase(ext, ".ssz") == 0:
|
if cmpIgnoreCase(ext, ".ssz") == 0:
|
||||||
SSZ.decode(bytes, T)
|
SSZ.decode(bytes, T)
|
||||||
elif cmpIgnoreCase(ext, ".ssz_snappy") == 0:
|
elif cmpIgnoreCase(ext, ".ssz_snappy") == 0:
|
||||||
|
@ -187,11 +187,12 @@ proc doSSZ(conf: NcliConf) =
|
||||||
of pretty: (conf.prettyKind, conf.prettyFile)
|
of pretty: (conf.prettyKind, conf.prettyFile)
|
||||||
else:
|
else:
|
||||||
raiseAssert "doSSZ() only implements hashTreeRoot and pretty commands"
|
raiseAssert "doSSZ() only implements hashTreeRoot and pretty commands"
|
||||||
|
let bytes = readAllBytes(file).expect("file exists")
|
||||||
|
|
||||||
template printit(t: untyped) {.dirty.} =
|
template printit(t: untyped) {.dirty.} =
|
||||||
|
|
||||||
let v = withTimerRet(timers[tLoad]):
|
let v = withTimerRet(timers[tLoad]):
|
||||||
newClone(loadFile(file, t))
|
newClone(loadFile(file, bytes, t))
|
||||||
|
|
||||||
case conf.cmd:
|
case conf.cmd:
|
||||||
of hashTreeRoot:
|
of hashTreeRoot:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c6aa85e1f59076eeabafa607ab8489f95fdbba20
|
Subproject commit 3b1f866e419527fdd4b36d054e94678c3035b879
|
Loading…
Reference in New Issue