From 22c187d0e377aacf78b636731f8bc22f357b17ff Mon Sep 17 00:00:00 2001 From: Edmund Noble Date: Tue, 18 Jun 2024 16:23:18 -0400 Subject: [PATCH] perf: stop replaying empty blocks Simply do not replay empty blocks and reap the performance rewards. I'm careful here to still keep any upgrade blocks. Change-Id: I601cb81cd5e241fa3ceaa315d80b33ae9f17c75d --- changes/2024-06-19T182611-0400.txt | 1 + src/Chainweb/Pact/PactService.hs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changes/2024-06-19T182611-0400.txt diff --git a/changes/2024-06-19T182611-0400.txt b/changes/2024-06-19T182611-0400.txt new file mode 100644 index 0000000000..f09e731a21 --- /dev/null +++ b/changes/2024-06-19T182611-0400.txt @@ -0,0 +1 @@ +Speed up read-only replay by avoiding playing empty blocks diff --git a/src/Chainweb/Pact/PactService.hs b/src/Chainweb/Pact/PactService.hs index cf4554eed4..34e3143392 100644 --- a/src/Chainweb/Pact/PactService.hs +++ b/src/Chainweb/Pact/PactService.hs @@ -824,7 +824,10 @@ execReadOnlyReplay lowerBound maybeUpperBound = pactLabel "execReadOnlyReplay" $ liftIO $ writeIORef heightRef (_blockHeight bh) payload <- liftIO $ fromJuste <$> lookupPayloadDataWithHeight pdb (Just $ _blockHeight bh) (_blockPayloadHash bh) - void $ execBlock bh (CheckablePayload payload) + let isPayloadEmpty = V.null (_payloadDataTransactions payload) + let isUpgradeBlock = isJust $ _chainwebVersion bhdb ^? versionUpgrades . onChain (_chainId bhdb) . ix (_blockHeight bh) + unless (isPayloadEmpty && not isUpgradeBlock) $ + void $ execBlock bh (CheckablePayload payload) ) validationFailed <- readIORef validationFailedRef when validationFailed $