2024-02-02 20:23:04 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-10-03 11:56:13 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or
|
|
|
|
# distributed except according to those terms.
|
|
|
|
|
|
|
|
import
|
2024-05-20 13:59:18 +00:00
|
|
|
std/[os, strformat, times],
|
2023-10-18 19:27:22 +00:00
|
|
|
chronicles,
|
2023-10-03 11:56:13 +00:00
|
|
|
eth/common,
|
|
|
|
results,
|
|
|
|
unittest2,
|
2023-12-12 17:47:41 +00:00
|
|
|
../../nimbus/core/chain,
|
|
|
|
../../nimbus/db/ledger,
|
2024-05-22 13:41:14 +00:00
|
|
|
../replay/[pp, undump_blocks, undump_blocks_era1, xcheck],
|
2023-10-03 11:56:13 +00:00
|
|
|
./test_helpers
|
|
|
|
|
2024-11-06 02:01:56 +00:00
|
|
|
when CoreDbEnableProfiling:
|
2024-07-12 19:32:31 +00:00
|
|
|
import
|
|
|
|
std/sequtils
|
|
|
|
|
2024-07-12 13:12:25 +00:00
|
|
|
when CoreDbEnableProfiling:
|
2024-02-29 21:10:24 +00:00
|
|
|
import
|
|
|
|
../../nimbus/db/aristo/[aristo_api, aristo_profile],
|
|
|
|
../../nimbus/db/kvt/kvt_api
|
|
|
|
var
|
|
|
|
aristoProfData: AristoDbProfListRef
|
|
|
|
kvtProfData: KvtDbProfListRef
|
|
|
|
cdbProfData: CoreDbProfListRef
|
|
|
|
|
2023-12-12 19:12:56 +00:00
|
|
|
const
|
|
|
|
EnableExtraLoggingControl = true
|
|
|
|
var
|
|
|
|
logStartTime {.used.} = Time()
|
2024-06-27 19:21:01 +00:00
|
|
|
logSavedEnv {.used.}: (bool,bool)
|
2023-12-12 17:47:41 +00:00
|
|
|
|
2023-10-03 11:56:13 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private helpers
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2023-10-18 19:27:22 +00:00
|
|
|
proc setTraceLevel {.used.} =
|
|
|
|
when defined(chronicles_runtime_filtering) and loggingEnabled:
|
|
|
|
setLogLevel(LogLevel.TRACE)
|
|
|
|
|
2023-12-12 19:12:56 +00:00
|
|
|
proc setDebugLevel {.used.} =
|
|
|
|
when defined(chronicles_runtime_filtering) and loggingEnabled:
|
|
|
|
setLogLevel(LogLevel.DEBUG)
|
|
|
|
|
2023-10-18 19:27:22 +00:00
|
|
|
proc setErrorLevel {.used.} =
|
|
|
|
when defined(chronicles_runtime_filtering) and loggingEnabled:
|
|
|
|
setLogLevel(LogLevel.ERROR)
|
|
|
|
|
2023-12-12 17:47:41 +00:00
|
|
|
# --------------
|
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
template initLogging(noisy: bool, com: CommonRef) =
|
2023-12-12 19:12:56 +00:00
|
|
|
when EnableExtraLoggingControl:
|
2024-02-02 20:23:04 +00:00
|
|
|
if noisy:
|
|
|
|
setDebugLevel()
|
|
|
|
debug "start undumping into persistent blocks"
|
2023-12-12 19:12:56 +00:00
|
|
|
logStartTime = Time()
|
|
|
|
setErrorLevel()
|
2024-07-12 13:12:25 +00:00
|
|
|
when CoreDbEnableApiTracking:
|
|
|
|
logSavedEnv = (com.db.trackCoreDbApi, com.db.trackLedgerApi)
|
|
|
|
com.db.trackCoreDbApi = true
|
|
|
|
com.db.trackLedgerApi = true
|
2023-12-12 19:12:56 +00:00
|
|
|
|
|
|
|
proc finishLogging(com: CommonRef) =
|
|
|
|
when EnableExtraLoggingControl:
|
|
|
|
setErrorLevel()
|
2024-07-12 13:12:25 +00:00
|
|
|
when CoreDbEnableApiTracking:
|
|
|
|
(com.db.trackCoreDbApi, com.db.trackLedgerApi) = logSavedEnv
|
2023-12-12 19:12:56 +00:00
|
|
|
|
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
template startLogging(noisy: bool; num: BlockNumber) =
|
|
|
|
when EnableExtraLoggingControl:
|
|
|
|
if noisy and logStartTime == Time():
|
|
|
|
logStartTime = getTime()
|
|
|
|
setDebugLevel()
|
|
|
|
debug "start logging ...", blockNumber=num
|
|
|
|
|
2024-02-16 09:08:07 +00:00
|
|
|
when false:
|
|
|
|
template startLogging(noisy: bool) =
|
|
|
|
when EnableExtraLoggingControl:
|
|
|
|
if noisy and logStartTime == Time():
|
|
|
|
logStartTime = getTime()
|
|
|
|
setDebugLevel()
|
|
|
|
debug "start logging ..."
|
2023-12-12 19:12:56 +00:00
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
template stopLogging(noisy: bool) =
|
2023-12-12 19:12:56 +00:00
|
|
|
when EnableExtraLoggingControl:
|
|
|
|
if logStartTime != Time():
|
|
|
|
debug "stop logging", elapsed=(getTime() - logStartTime).pp
|
|
|
|
logStartTime = Time()
|
|
|
|
setErrorLevel()
|
|
|
|
|
|
|
|
template stopLoggingAfter(noisy: bool; code: untyped) =
|
|
|
|
## Turn logging off after executing `block`
|
|
|
|
block:
|
|
|
|
defer: noisy.stopLogging()
|
|
|
|
code
|
|
|
|
|
2023-10-03 11:56:13 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public test function
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2023-12-12 17:47:41 +00:00
|
|
|
proc test_chainSyncProfilingPrint*(
|
|
|
|
noisy = false;
|
|
|
|
nBlocks: int;
|
2024-02-29 21:10:24 +00:00
|
|
|
indent = 2;
|
2023-12-12 17:47:41 +00:00
|
|
|
) =
|
|
|
|
if noisy:
|
|
|
|
let info =
|
|
|
|
if 0 < nBlocks and nBlocks < high(int): " (" & $nBlocks & " blocks)"
|
|
|
|
else: ""
|
2024-03-20 07:35:38 +00:00
|
|
|
discard info
|
2024-02-29 21:10:24 +00:00
|
|
|
var blurb: seq[string]
|
2024-07-12 13:12:25 +00:00
|
|
|
when CoreDbEnableProfiling:
|
2024-02-29 21:10:24 +00:00
|
|
|
blurb.add cdbProfData.profilingPrinter(
|
|
|
|
names = CoreDbFnInx.toSeq.mapIt($it),
|
|
|
|
header = "CoreDb profiling results" & info,
|
|
|
|
indent)
|
|
|
|
blurb.add aristoProfData.profilingPrinter(
|
|
|
|
names = AristoApiProfNames.toSeq.mapIt($it),
|
|
|
|
header = "Aristo backend profiling results" & info,
|
|
|
|
indent)
|
|
|
|
blurb.add kvtProfData.profilingPrinter(
|
|
|
|
names = KvtApiProfNames.toSeq.mapIt($it),
|
|
|
|
header = "Kvt backend profiling results" & info,
|
|
|
|
indent)
|
|
|
|
for s in blurb:
|
2023-12-12 17:47:41 +00:00
|
|
|
if 0 < s.len: true.say "***", s, "\n"
|
|
|
|
|
2023-10-25 14:03:09 +00:00
|
|
|
proc test_chainSync*(
|
2023-10-03 11:56:13 +00:00
|
|
|
noisy: bool;
|
2024-02-09 13:30:07 +00:00
|
|
|
filePaths: seq[string];
|
2023-10-03 11:56:13 +00:00
|
|
|
com: CommonRef;
|
2023-10-18 19:27:22 +00:00
|
|
|
numBlocks = high(int);
|
2023-12-12 19:12:56 +00:00
|
|
|
enaLogging = true;
|
2024-05-30 17:48:38 +00:00
|
|
|
lastOneExtra = true;
|
|
|
|
oldLogAlign = false;
|
2023-10-03 11:56:13 +00:00
|
|
|
): bool =
|
|
|
|
## Store persistent blocks from dump into chain DB
|
|
|
|
let
|
2024-06-14 07:31:08 +00:00
|
|
|
sayBlocks = 900'u64
|
2024-12-18 04:04:23 +00:00
|
|
|
chain = com.newChain()
|
2024-05-31 17:32:22 +00:00
|
|
|
blockOnDb = com.db.getSavedStateBlockNumber()
|
2024-06-14 07:31:08 +00:00
|
|
|
lastBlock = max(1, numBlocks).BlockNumber
|
2023-12-12 19:12:56 +00:00
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
noisy.initLogging com
|
2023-12-12 19:12:56 +00:00
|
|
|
defer: com.finishLogging()
|
2023-10-03 11:56:13 +00:00
|
|
|
|
2024-05-22 13:41:14 +00:00
|
|
|
# Scan folder for `era1` files (ignoring the argument file name)
|
|
|
|
let
|
|
|
|
(dir, _, ext) = filePaths[0].splitFile
|
|
|
|
files =
|
|
|
|
if filePaths.len == 1 and ext == ".era1":
|
|
|
|
@[dir]
|
|
|
|
else:
|
|
|
|
filePaths
|
|
|
|
|
|
|
|
# If the least block is non-zero, resume at the next block
|
|
|
|
let start = block:
|
|
|
|
if blockOnDb == 0:
|
|
|
|
0u64
|
|
|
|
elif blockOnDb < lastBlock:
|
|
|
|
noisy.say "***", "resuming at #", blockOnDb+1
|
2024-06-14 07:31:08 +00:00
|
|
|
blockOnDb + 1
|
2024-05-22 13:41:14 +00:00
|
|
|
else:
|
|
|
|
noisy.say "***", "stop: sample exhausted"
|
|
|
|
return true
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
# Profile variables will be non-nil if profiling is available. The profiling
|
|
|
|
# API data need to be captured so it will be available after the services
|
|
|
|
# have terminated.
|
2024-07-12 13:12:25 +00:00
|
|
|
when CoreDbEnableProfiling:
|
2024-07-03 15:50:27 +00:00
|
|
|
aristoProfData = com.db.ariApi.AristoApiProfRef.data
|
|
|
|
kvtProfData = com.db.kvtApi.KvtApiProfRef.data
|
|
|
|
cdbProfData = com.db.profTab
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-05-22 13:41:14 +00:00
|
|
|
# This will enable printing the `era1` covered block ranges (if any)
|
|
|
|
undump_blocks_era1.noisy = noisy
|
2024-05-20 13:59:18 +00:00
|
|
|
|
2024-05-23 15:37:51 +00:00
|
|
|
var
|
|
|
|
blocks = 0
|
|
|
|
total = 0
|
|
|
|
begin = toUnixFloat(getTime())
|
|
|
|
sample = begin
|
|
|
|
|
|
|
|
template sayPerf =
|
|
|
|
if blocks > 0:
|
|
|
|
total += blocks
|
|
|
|
let done {.inject.} = toUnixFloat(getTime())
|
2024-05-30 17:48:38 +00:00
|
|
|
noisy.say "", &"{blocks:3} blocks, {(done-sample):2.3}s,",
|
|
|
|
" {(blocks.float / (done-sample)):4.3f} b/s,",
|
|
|
|
" avg {(total.float / (done-begin)):4.3f} b/s"
|
2024-05-23 15:37:51 +00:00
|
|
|
blocks = 0
|
|
|
|
sample = done
|
|
|
|
|
2024-05-22 13:41:14 +00:00
|
|
|
for w in files.undumpBlocks(least = start):
|
2024-06-14 07:31:08 +00:00
|
|
|
let (fromBlock, toBlock) = (w[0].header.number, w[^1].header.number)
|
|
|
|
if fromBlock == 0'u64:
|
2024-11-07 01:24:21 +00:00
|
|
|
xCheck w[0].header == com.db.getBlockHeader(0'u64).expect("block header exists")
|
2023-10-03 11:56:13 +00:00
|
|
|
continue
|
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
# Process groups of blocks ...
|
2023-10-18 19:27:22 +00:00
|
|
|
if toBlock < lastBlock:
|
|
|
|
# Message if `[fromBlock,toBlock]` contains a multiple of `sayBlocks`
|
2024-06-14 07:31:08 +00:00
|
|
|
if fromBlock + (toBlock mod sayBlocks) <= toBlock:
|
2024-05-30 17:48:38 +00:00
|
|
|
if oldLogAlign:
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing ...[#{fromBlock},#{toBlock}]...\n"
|
|
|
|
else:
|
|
|
|
sayPerf
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing ...[#{fromBlock:>8},#{toBlock:>8}]..."
|
2023-12-12 19:12:56 +00:00
|
|
|
if enaLogging:
|
2024-06-14 07:31:08 +00:00
|
|
|
noisy.startLogging(w[0].header.number)
|
2024-05-23 15:37:51 +00:00
|
|
|
|
2023-12-12 19:12:56 +00:00
|
|
|
noisy.stopLoggingAfter():
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
let runPersistBlocksRc = chain.persistBlocks(w)
|
2024-05-31 07:13:56 +00:00
|
|
|
xCheck runPersistBlocksRc.isOk():
|
2023-12-12 19:12:56 +00:00
|
|
|
if noisy:
|
2024-05-30 17:48:38 +00:00
|
|
|
noisy.whisper "***", "Re-run with logging enabled...\n"
|
2023-12-12 19:12:56 +00:00
|
|
|
setTraceLevel()
|
2024-07-12 13:12:25 +00:00
|
|
|
when CoreDbEnableApiTracking:
|
|
|
|
com.db.trackCoreDbApi = false
|
|
|
|
com.db.trackLedgerApi = false
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
discard chain.persistBlocks(w)
|
|
|
|
blocks += w.len
|
2023-10-18 19:27:22 +00:00
|
|
|
continue
|
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
# Last group or single block
|
|
|
|
#
|
2023-10-18 19:27:22 +00:00
|
|
|
# Make sure that the `lastBlock` is the first item of the argument batch.
|
|
|
|
# So It might be necessary to Split off all blocks smaller than `lastBlock`
|
|
|
|
# and execute them first. Then the next batch starts with the `lastBlock`.
|
|
|
|
let
|
2024-06-14 07:31:08 +00:00
|
|
|
pivot = lastBlock - fromBlock
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
blocks9 = w[pivot .. ^1]
|
2024-06-14 07:31:08 +00:00
|
|
|
doAssert lastBlock == blocks9[0].header.number
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2024-05-22 13:41:14 +00:00
|
|
|
# Process leading batch before `lastBlock` (if any)
|
2023-10-18 19:27:22 +00:00
|
|
|
var dotsOrSpace = "..."
|
|
|
|
if fromBlock < lastBlock:
|
|
|
|
let
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
blocks1 = w[0 ..< pivot]
|
2024-05-30 17:48:38 +00:00
|
|
|
if oldLogAlign:
|
|
|
|
noisy.whisper "***", &"processing ...[#{fromBlock},#{toBlock}]...\n"
|
|
|
|
else:
|
|
|
|
sayPerf
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing {dotsOrSpace}[#{fromBlock:>8},#{(lastBlock-1):>8}]"
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
let runPersistBlocks1Rc = chain.persistBlocks(blocks1)
|
2024-05-31 07:13:56 +00:00
|
|
|
xCheck runPersistBlocks1Rc.isOk()
|
2023-10-18 19:27:22 +00:00
|
|
|
dotsOrSpace = " "
|
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
noisy.startLogging(blocks9[0].header.number)
|
2023-10-18 19:27:22 +00:00
|
|
|
if lastOneExtra:
|
|
|
|
let
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
blocks0 = blocks9[0..0]
|
2024-05-30 17:48:38 +00:00
|
|
|
if oldLogAlign:
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing {dotsOrSpace}[#{fromBlock},#{lastBlock-1}]\n"
|
|
|
|
else:
|
|
|
|
sayPerf
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing {dotsOrSpace}[#{lastBlock:>8},#{lastBlock:>8}]"
|
2023-12-12 19:12:56 +00:00
|
|
|
noisy.stopLoggingAfter():
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
let runPersistBlocks0Rc = chain.persistBlocks(blocks0)
|
2024-05-31 07:13:56 +00:00
|
|
|
xCheck runPersistBlocks0Rc.isOk()
|
2023-10-18 19:27:22 +00:00
|
|
|
else:
|
2024-05-30 17:48:38 +00:00
|
|
|
if oldLogAlign:
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing {dotsOrSpace}[#{lastBlock},#{toBlock}]\n"
|
|
|
|
else:
|
|
|
|
sayPerf
|
|
|
|
noisy.whisper "***",
|
|
|
|
&"processing {dotsOrSpace}[#{lastBlock:>8},#{toBlock:>8}]"
|
2023-12-12 19:12:56 +00:00
|
|
|
noisy.stopLoggingAfter():
|
Consolidate block type for block processing (#2325)
This PR consolidates the split header-body sequences into a single EthBlock
sequence and cleans up the fallout from that which significantly reduces
block processing overhead during import thanks to less garbage collection
and fewer copies of things all around.
Notably, since the number of headers must always match the number of bodies,
we also get rid of a pointless degree of freedom that in the future could
introduce unnecessary bugs.
* only read header and body from era file
* avoid several unnecessary copies along the block processing way
* simplify signatures, cleaning up unused arguemnts and returns
* use `stew/assign2` in a few strategic places where the generated
nim assignent is slow and add a few `move` to work around poor
analysis in nim 1.6 (will need to be revisited for 2.0)
```
stats-20240607_2223-a814aa0b.csv vs stats-20240608_0714-21c1d0a9.csv
bps_x bps_y tps_x tps_y bpsd tpsd timed
block_number
(498305, 713245] 1,540.52 1,809.73 2,361.58 2775.340189 17.63% 17.63% -14.92%
(713245, 928185] 730.36 865.26 1,715.90 2028.973852 18.01% 18.01% -15.21%
(928185, 1143126] 663.03 789.10 2,529.26 3032.490771 19.79% 19.79% -16.28%
(1143126, 1358066] 393.46 508.05 2,152.50 2777.578119 29.13% 29.13% -22.50%
(1358066, 1573007] 370.88 440.72 2,351.31 2791.896052 18.81% 18.81% -15.80%
(1573007, 1787947] 283.65 335.11 2,068.93 2441.373402 17.60% 17.60% -14.91%
(1787947, 2002888] 287.29 342.11 2,078.39 2474.179448 18.99% 18.99% -15.91%
(2002888, 2217828] 293.38 343.16 2,208.83 2584.77457 17.16% 17.16% -14.61%
(2217828, 2432769] 140.09 167.86 1,081.87 1296.336926 18.82% 18.82% -15.80%
blocks: 1934464, baseline: 3h13m1s, contender: 2h43m47s
bpsd (mean): 19.55%
tpsd (mean): 19.55%
Time (total): -29m13s, -15.14%
```
2024-06-09 14:32:20 +00:00
|
|
|
let runPersistBlocks9Rc = chain.persistBlocks(blocks9)
|
2024-05-31 07:13:56 +00:00
|
|
|
xCheck runPersistBlocks9Rc.isOk()
|
2023-10-18 19:27:22 +00:00
|
|
|
break
|
2024-05-30 17:48:38 +00:00
|
|
|
if not oldLogAlign:
|
|
|
|
sayPerf
|
2023-10-03 11:56:13 +00:00
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|