tns: checkpoint wal periodically while backfilling (#3516)
Witout this, we end up with a massive .wal file that needs to be checkpointed on first startup (which takes a few minutes) - it's much more efficient to do smaller checkpoints, it turns out.
This commit is contained in:
parent
8395f7de8c
commit
b3d80827fb
|
@ -1836,6 +1836,7 @@ proc rebuildIndex*(dag: ChainDAGRef) =
|
||||||
|
|
||||||
withState(state[]):
|
withState(state[]):
|
||||||
dag.db.putState(state)
|
dag.db.putState(state)
|
||||||
|
dag.db.checkpoint()
|
||||||
|
|
||||||
state_root = state.root
|
state_root = state.root
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ proc doTrustedNodeSync*(
|
||||||
|
|
||||||
let
|
let
|
||||||
db = BeaconChainDB.new(databaseDir, inMemory = false)
|
db = BeaconChainDB.new(databaseDir, inMemory = false)
|
||||||
|
defer:
|
||||||
|
db.close()
|
||||||
|
|
||||||
var
|
var
|
||||||
dbCache = DbCache(summaries: db.loadSummaries())
|
dbCache = DbCache(summaries: db.loadSummaries())
|
||||||
|
@ -391,6 +393,9 @@ proc doTrustedNodeSync*(
|
||||||
continue
|
continue
|
||||||
|
|
||||||
gets[int(i mod gets.lenu64)] = downloadBlock(slot)
|
gets[int(i mod gets.lenu64)] = downloadBlock(slot)
|
||||||
|
|
||||||
|
if i mod 1024 == 0:
|
||||||
|
db.checkpoint() # Transfer stuff from wal periodically
|
||||||
true
|
true
|
||||||
else:
|
else:
|
||||||
notice "Database initialized, historical blocks will be backfilled when starting the node",
|
notice "Database initialized, historical blocks will be backfilled when starting the node",
|
||||||
|
|
Loading…
Reference in New Issue