Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd, core, eth, light, trie: dump clean cache periodically #20391

Merged
merged 6 commits into from
Jul 28, 2020

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Nov 26, 2019

This PR enables the cache dump and reload from a disk journal.

Accumulate more entries in memory will help us to speed up. However
warm-up the cache can take a few minutes. So disk based journal can help
a lot.

Besides all entries we maintain in the cache is contract code and trie nodes.
The key of entries is essentially the hash of value. So we can blindly reload the
entries from journal and don't need to take care of the validity of data.

@rjl493456442 rjl493456442 changed the title [WIP] cmd, core, eth, light, trie: dump clean cache periodically cmd, core, eth, light, trie: dump clean cache periodically Nov 26, 2019
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, needs some testing I guess. IIUC, even if we merge this, it will by default do nothing, right?

@rjl493456442
Copy link
Member Author

@holiman nope, the cache dump and reload is enabled by default. And also users can specify the flags to change the behaviors.

core/blockchain.go Outdated Show resolved Hide resolved
core/blockchain.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated
log.Info("Failed to save clean cache into file", "error", err)
}
}(time.Now())
err = db.cleans.SaveToFileConcurrent(dir, threads)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we'd not want to use max concurrency here? I'd just set this to 0 and let fastcache max out the performance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much time does it take to persist a 1GB cache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember the concrete number, but a few seconds.

trie/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
@adamschmideg adamschmideg added this to the 1.9.13 milestone Apr 7, 2020
@karalabe karalabe modified the milestones: 1.9.13, 1.9.14 Apr 20, 2020
@karalabe karalabe modified the milestones: 1.9.14, 1.9.15 May 13, 2020
@karalabe karalabe modified the milestones: 1.9.15, 1.9.16 Jun 8, 2020
@fjl fjl modified the milestones: 1.9.16, 1.9.17 Jul 10, 2020
@karalabe karalabe modified the milestones: 1.9.17, 1.9.18 Jul 20, 2020
@karalabe karalabe modified the milestones: 1.9.18, 1.9.19 Jul 27, 2020
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karalabe karalabe merged commit 93da0cf into ethereum:master Jul 28, 2020
enriquefynn pushed a commit to enriquefynn/go-ethereum that referenced this pull request Mar 10, 2021
…20391)

* cmd, core, eth, light, trie: dump clean cache periodically

* eth: update config

* trie: minor fix

* core, trie: address comments

* eth: remove useless

* trie: print clean cache dump start too

Co-authored-by: Péter Szilágyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants