From b39e71335d8485a3cf744fdb7f7e3abf406e7865 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Tue, 15 Aug 2023 15:28:33 +0200 Subject: [PATCH] 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 --- ncli/ncli.nim | 7 ++++--- vendor/nim-ssz-serialization | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ncli/ncli.nim b/ncli/ncli.nim index 97bd88064..9f76ba2cd 100644 --- a/ncli/ncli.nim +++ b/ncli/ncli.nim @@ -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: diff --git a/vendor/nim-ssz-serialization b/vendor/nim-ssz-serialization index c6aa85e1f..3b1f866e4 160000 --- a/vendor/nim-ssz-serialization +++ b/vendor/nim-ssz-serialization @@ -1 +1 @@ -Subproject commit c6aa85e1f59076eeabafa607ab8489f95fdbba20 +Subproject commit 3b1f866e419527fdd4b36d054e94678c3035b879