mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 21:26:42 +00:00
force flush controlled in state_sizer
This commit is contained in:
parent
e1469bc414
commit
02474bd0bc
4 changed files with 12 additions and 13 deletions
|
|
@ -536,7 +536,6 @@ func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine,
|
|||
stateSizer, err := state.NewSizeTracker(bc.db, bc.triedb)
|
||||
if err == nil {
|
||||
bc.stateSizer = stateSizer
|
||||
triedb.EnableForceFlush()
|
||||
} else {
|
||||
log.Info("Failed to setup size tracker", "err", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -360,6 +360,8 @@ wait:
|
|||
done chan buildResult
|
||||
)
|
||||
|
||||
t.triedb.SetForceFlush(true)
|
||||
|
||||
for {
|
||||
select {
|
||||
case u := <-t.updateCh:
|
||||
|
|
@ -384,6 +386,8 @@ wait:
|
|||
log.Info("Measuring persistent state size", "root", root.Hex())
|
||||
|
||||
case result := <-done:
|
||||
t.triedb.SetForceFlush(false)
|
||||
|
||||
if result.err != nil {
|
||||
return nil, result.err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,11 +385,11 @@ func (db *Database) SnapshotCompleted() bool {
|
|||
return pdb.SnapshotCompleted()
|
||||
}
|
||||
|
||||
// EnableForceFlush enables the pathdb to flush any pending changes to disk immediately,
|
||||
// regardless of the buffer size threshold. This can be used to accelerate
|
||||
// SetForceFlush enables or disables the pathdb to flush any pending changes to disk
|
||||
// immediately, regardless of the buffer size threshold. This can be used to accelerate
|
||||
// state sizer initialization by making buffered state changes visible on disk.
|
||||
func (db *Database) EnableForceFlush() {
|
||||
func (db *Database) SetForceFlush(enabled bool) {
|
||||
if pdb, ok := db.backend.(*pathdb.Database); ok {
|
||||
pdb.EnableForceFlush()
|
||||
pdb.SetForceFlush(enabled)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,17 +361,13 @@ func (db *Database) Commit(root common.Hash, report bool) error {
|
|||
return db.tree.cap(root, 0)
|
||||
}
|
||||
|
||||
// EnableForceFlush enables force flushing for the next state update.
|
||||
// This will cause the next Update() call to flush the disk buffer immediately,
|
||||
// regardless of the buffer threshold, while preserving the 128 diff layers in memory.
|
||||
func (db *Database) EnableForceFlush() {
|
||||
// SetForceFlush enables or disables force flushing for the next state update.
|
||||
func (db *Database) SetForceFlush(enabled bool) {
|
||||
db.lock.Lock()
|
||||
defer db.lock.Unlock()
|
||||
|
||||
if !db.forceFlush {
|
||||
log.Info("Enabling force flush for next pathdb update")
|
||||
db.forceFlush = true
|
||||
}
|
||||
db.forceFlush = enabled
|
||||
log.Info("Set triedb force flush for next pathdb update", "enabled", enabled)
|
||||
}
|
||||
|
||||
// Disable deactivates the database and invalidates all available state layers
|
||||
|
|
|
|||
Loading…
Reference in a new issue