mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
core/rawdb: change the mechanism to schedule freezer sync
This commit is contained in:
parent
fe0ae06c77
commit
b17db544cf
2 changed files with 5 additions and 1 deletions
|
|
@ -201,6 +201,7 @@ func (batch *freezerTableBatch) commit() error {
|
||||||
|
|
||||||
// Update headBytes of table.
|
// Update headBytes of table.
|
||||||
batch.t.headBytes += dataSize
|
batch.t.headBytes += dataSize
|
||||||
|
items := batch.curItem - batch.t.items.Load()
|
||||||
batch.t.items.Store(batch.curItem)
|
batch.t.items.Store(batch.curItem)
|
||||||
|
|
||||||
// Update metrics.
|
// Update metrics.
|
||||||
|
|
@ -208,7 +209,9 @@ func (batch *freezerTableBatch) commit() error {
|
||||||
batch.t.writeMeter.Mark(dataSize + indexSize)
|
batch.t.writeMeter.Mark(dataSize + indexSize)
|
||||||
|
|
||||||
// Periodically sync the table, todo (rjl493456442) make it configurable?
|
// Periodically sync the table, todo (rjl493456442) make it configurable?
|
||||||
if time.Since(batch.t.lastSync) > 30*time.Second {
|
batch.t.uncommit += items
|
||||||
|
if batch.t.uncommit > 256 && time.Since(batch.t.lastSync) > 30*time.Second {
|
||||||
|
batch.t.uncommit = 0
|
||||||
batch.t.lastSync = time.Now()
|
batch.t.lastSync = time.Now()
|
||||||
return batch.t.Sync()
|
return batch.t.Sync()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ type freezerTable struct {
|
||||||
tailId uint32 // number of the earliest file
|
tailId uint32 // number of the earliest file
|
||||||
|
|
||||||
metadata *freezerTableMeta // metadata of the table
|
metadata *freezerTableMeta // metadata of the table
|
||||||
|
uncommit uint64 // Count of items written without flushing to file
|
||||||
lastSync time.Time // Timestamp when the last sync was performed
|
lastSync time.Time // Timestamp when the last sync was performed
|
||||||
|
|
||||||
headBytes int64 // Number of bytes written to the head file
|
headBytes int64 // Number of bytes written to the head file
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue