2024-05-31 07:13:56 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2024 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
2024-06-02 11:00:05 +00:00
|
|
|
{.push raises: [].}
|
|
|
|
|
2024-05-31 07:13:56 +00:00
|
|
|
import
|
|
|
|
chronicles,
|
2024-06-20 17:06:58 +00:00
|
|
|
metrics,
|
2024-06-02 11:00:05 +00:00
|
|
|
chronos/timer,
|
2024-06-06 05:03:11 +00:00
|
|
|
std/[strformat, strutils],
|
2024-05-31 07:13:56 +00:00
|
|
|
stew/io2,
|
|
|
|
./config,
|
|
|
|
./common/common,
|
|
|
|
./core/[block_import, chain],
|
|
|
|
./db/era1_db,
|
|
|
|
beacon_chain/era_db
|
|
|
|
|
2024-06-24 05:56:41 +00:00
|
|
|
declareGauge nec_import_block_number,
|
|
|
|
"Latest imported block number"
|
|
|
|
|
2024-06-20 17:06:58 +00:00
|
|
|
declareCounter nec_imported_blocks,
|
|
|
|
"Blocks processed during import"
|
|
|
|
|
|
|
|
declareCounter nec_imported_transactions,
|
|
|
|
"Transactions processed during import"
|
|
|
|
|
|
|
|
declareCounter nec_imported_gas,
|
|
|
|
"Gas processed during import"
|
|
|
|
|
2024-05-31 07:13:56 +00:00
|
|
|
var running {.volatile.} = true
|
|
|
|
|
2024-06-02 11:00:05 +00:00
|
|
|
func shortLog(a: timer.Duration, parts = int.high): string {.inline.} =
|
|
|
|
## Returns string representation of Duration ``a`` as nanoseconds value.
|
|
|
|
var
|
|
|
|
res = ""
|
|
|
|
v = a.nanoseconds()
|
|
|
|
parts = parts
|
|
|
|
|
|
|
|
template f(n: string, T: Duration) =
|
|
|
|
if v >= T.nanoseconds():
|
|
|
|
res.add($(uint64(v div T.nanoseconds())))
|
|
|
|
res.add(n)
|
|
|
|
v = v mod T.nanoseconds()
|
|
|
|
dec parts
|
2024-06-06 05:03:11 +00:00
|
|
|
if v == 0 or parts <= 0:
|
|
|
|
return res
|
2024-06-02 11:00:05 +00:00
|
|
|
|
|
|
|
f("w", Week)
|
|
|
|
f("d", Day)
|
|
|
|
f("h", Hour)
|
|
|
|
f("m", Minute)
|
|
|
|
f("s", Second)
|
|
|
|
f("ms", Millisecond)
|
|
|
|
f("us", Microsecond)
|
|
|
|
f("ns", Nanosecond)
|
|
|
|
|
|
|
|
res
|
|
|
|
|
2024-05-31 07:13:56 +00:00
|
|
|
proc importBlocks*(conf: NimbusConf, com: CommonRef) =
|
|
|
|
proc controlCHandler() {.noconv.} =
|
|
|
|
when defined(windows):
|
|
|
|
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
|
|
|
setupForeignThreadGc()
|
|
|
|
running = false
|
|
|
|
|
|
|
|
setControlCHook(controlCHandler)
|
|
|
|
|
|
|
|
let
|
2024-06-14 07:31:08 +00:00
|
|
|
start = com.db.getSavedStateBlockNumber() + 1
|
2024-05-31 07:13:56 +00:00
|
|
|
chain = com.newChain()
|
|
|
|
|
2024-06-15 09:22:37 +00:00
|
|
|
template boolFlag(flags, b): PersistBlockFlags =
|
|
|
|
if b:
|
|
|
|
flags
|
|
|
|
else:
|
|
|
|
{}
|
|
|
|
|
2024-05-31 07:13:56 +00:00
|
|
|
var
|
|
|
|
imported = 0'u64
|
2024-06-14 05:10:00 +00:00
|
|
|
gas = GasInt(0)
|
2024-05-31 07:13:56 +00:00
|
|
|
txs = 0
|
2024-06-02 11:00:05 +00:00
|
|
|
time0 = Moment.now()
|
2024-06-06 05:03:11 +00:00
|
|
|
csv =
|
|
|
|
if conf.csvStats.isSome:
|
|
|
|
try:
|
|
|
|
let f = open(conf.csvStats.get(), fmAppend)
|
|
|
|
if f.getFileSize() == 0:
|
|
|
|
f.writeLine("block_number,blocks,txs,gas,time")
|
|
|
|
f
|
|
|
|
except IOError as exc:
|
|
|
|
error "Could not open statistics output file",
|
|
|
|
file = conf.csvStats, err = exc.msg
|
|
|
|
quit(QuitFailure)
|
|
|
|
else:
|
|
|
|
File(nil)
|
2024-06-15 09:22:37 +00:00
|
|
|
flags =
|
|
|
|
boolFlag({PersistBlockFlag.NoFullValidation}, not conf.fullValidation) +
|
|
|
|
boolFlag(NoPersistBodies, not conf.storeBodies) +
|
|
|
|
boolFlag({PersistBlockFlag.NoPersistReceipts}, not conf.storeReceipts)
|
|
|
|
|
2024-06-06 05:03:11 +00:00
|
|
|
defer:
|
|
|
|
if csv != nil:
|
|
|
|
close(csv)
|
|
|
|
|
2024-06-24 05:56:41 +00:00
|
|
|
nec_import_block_number.set(start.int64)
|
|
|
|
|
2024-05-31 07:13:56 +00:00
|
|
|
template blockNumber(): uint64 =
|
|
|
|
start + imported
|
|
|
|
|
|
|
|
if isDir(conf.era1Dir.string):
|
|
|
|
doAssert conf.networkId == MainNet, "Only mainnet era1 current supported"
|
|
|
|
|
|
|
|
const
|
|
|
|
# TODO the merge block number could be fetched from the era1 file instead,
|
|
|
|
# specially if the accumulator is added to the chain metadata
|
|
|
|
lastEra1Block = 15537393
|
|
|
|
|
|
|
|
if start <= lastEra1Block:
|
|
|
|
notice "Importing era1 archive",
|
|
|
|
start, dataDir = conf.dataDir.string, era1Dir = conf.era1Dir.string
|
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
|
|
|
var blocks: seq[EthBlock]
|
2024-05-31 07:13:56 +00:00
|
|
|
|
|
|
|
func f(value: float): string =
|
2024-06-02 11:00:05 +00:00
|
|
|
try:
|
|
|
|
&"{value:4.3f}"
|
|
|
|
except ValueError:
|
|
|
|
raiseAssert "valid fmt string"
|
2024-05-31 07:13:56 +00:00
|
|
|
|
|
|
|
template process() =
|
|
|
|
let
|
2024-06-02 11:00:05 +00:00
|
|
|
time1 = Moment.now()
|
2024-06-15 09:22:37 +00:00
|
|
|
statsRes = chain.persistBlocks(blocks, flags)
|
2024-05-31 07:13:56 +00:00
|
|
|
if statsRes.isErr():
|
|
|
|
error "Failed to persist blocks", error = statsRes.error
|
|
|
|
quit(QuitFailure)
|
|
|
|
|
|
|
|
txs += statsRes[].txs
|
2024-06-14 05:10:00 +00:00
|
|
|
gas += statsRes[].gas
|
2024-05-31 07:13:56 +00:00
|
|
|
let
|
2024-06-02 11:00:05 +00:00
|
|
|
time2 = Moment.now()
|
|
|
|
diff1 = (time2 - time1).nanoseconds().float / 1000000000
|
|
|
|
diff0 = (time2 - time0).nanoseconds().float / 1000000000
|
2024-05-31 07:13:56 +00:00
|
|
|
|
|
|
|
info "Imported blocks",
|
|
|
|
blockNumber,
|
2024-06-02 11:00:05 +00:00
|
|
|
blocks = imported,
|
|
|
|
txs,
|
2024-06-14 05:10:00 +00:00
|
|
|
mgas = f(gas.float / 1000000),
|
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
|
|
|
bps = f(blocks.len.float / diff1),
|
2024-05-31 07:13:56 +00:00
|
|
|
tps = f(statsRes[].txs.float / diff1),
|
2024-06-14 05:10:00 +00:00
|
|
|
mgps = f(statsRes[].gas.float / 1000000 / diff1),
|
2024-05-31 07:13:56 +00:00
|
|
|
avgBps = f(imported.float / diff0),
|
2024-06-02 11:00:05 +00:00
|
|
|
avgTps = f(txs.float / diff0),
|
2024-06-14 05:10:00 +00:00
|
|
|
avgMGps = f(gas.float / 1000000 / diff0),
|
2024-06-06 05:03:11 +00:00
|
|
|
elapsed = shortLog(time2 - time0, 3)
|
|
|
|
|
2024-06-24 05:56:41 +00:00
|
|
|
metrics.set(nec_import_block_number, int64(blockNumber))
|
2024-06-20 17:06:58 +00:00
|
|
|
nec_imported_blocks.inc(blocks.len)
|
|
|
|
nec_imported_transactions.inc(statsRes[].txs)
|
|
|
|
nec_imported_gas.inc(statsRes[].gas)
|
|
|
|
|
2024-06-06 05:03:11 +00:00
|
|
|
if csv != nil:
|
|
|
|
# In the CSV, we store a line for every chunk of blocks processed so
|
|
|
|
# that the file can meaningfully be appended to when restarting the
|
|
|
|
# process - this way, each sample is independent
|
|
|
|
try:
|
|
|
|
csv.writeLine(
|
|
|
|
[
|
|
|
|
$blockNumber,
|
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
|
|
|
$blocks.len,
|
2024-06-06 05:03:11 +00:00
|
|
|
$statsRes[].txs,
|
|
|
|
$statsRes[].gas,
|
|
|
|
$(time2 - time1).nanoseconds(),
|
|
|
|
].join(",")
|
|
|
|
)
|
|
|
|
csv.flushFile()
|
|
|
|
except IOError as exc:
|
|
|
|
warn "Could not write csv", err = exc.msg
|
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
|
|
|
blocks.setLen(0)
|
2024-05-31 07:13:56 +00:00
|
|
|
|
|
|
|
let db =
|
|
|
|
Era1DbRef.init(conf.era1Dir.string, "mainnet").expect("Era files present")
|
|
|
|
defer:
|
|
|
|
db.dispose()
|
|
|
|
|
|
|
|
while running and imported < conf.maxBlocks and blockNumber <= lastEra1Block:
|
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
|
|
|
var blk = db.getEthBlock(blockNumber).valueOr:
|
2024-05-31 07:13:56 +00:00
|
|
|
error "Could not load block from era1", blockNumber, error
|
|
|
|
break
|
|
|
|
|
|
|
|
imported += 1
|
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
|
|
|
blocks.add move(blk)
|
2024-05-31 07:13:56 +00:00
|
|
|
|
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
|
|
|
if blocks.lenu64 mod conf.chunkSize == 0:
|
2024-05-31 07:13:56 +00:00
|
|
|
process()
|
|
|
|
|
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
|
|
|
if blocks.len > 0:
|
2024-05-31 07:13:56 +00:00
|
|
|
process() # last chunk, if any
|
|
|
|
|
|
|
|
for blocksFile in conf.blocksFile:
|
|
|
|
if isFile(string blocksFile):
|
|
|
|
# success or not, we quit after importing blocks
|
|
|
|
if not importRlpBlock(string blocksFile, com):
|
|
|
|
quit(QuitFailure)
|
|
|
|
else:
|
|
|
|
quit(QuitSuccess)
|