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

core, ethdb, trie: mode dirty data to clean cache on flush #19307

Merged
merged 5 commits into from
Mar 26, 2019

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Mar 21, 2019

This PR is a more advanced form of the dirty-to-clean cacher (#18995), where we reuse previous database write batches as datasets to uncache, saving a dirty-trie-iteration and a dirty-trie-rlp-reencoding per block.

@holiman holiman requested a review from karalabe as a code owner March 21, 2019 09:18
@karalabe karalabe changed the title Poc core, ethdb, trie: mode dirty data to clean cache on flush Mar 25, 2019
@karalabe karalabe added this to the 1.9.0 milestone Mar 25, 2019
ethdb/batch.go Outdated Show resolved Hide resolved
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

trie/database.go Outdated
db.lock.Unlock()
batch.Reset()
}
db.lock.RLock()
Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is a cluster-f*ck. That said, the trie database write access is serialized by the blockchain importer, since we can't import two blocks concurrently. The only thing this code needs to ensure is that API CALL operations, sync state retrievals, etc don't mess up. The blockchain guarantees that no write will intervene here.

ethdb/database.go Outdated Show resolved Hide resolved
trie/database.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

As per our long discussion on Discord, please remove read locking from Commit and Cap. Please also document that Commit and Cap are not safe for concurrent use.

@fjl fjl merged commit 59e1953 into ethereum:master Mar 26, 2019
kiku-jw pushed a commit to kiku-jw/go-ethereum that referenced this pull request Mar 29, 2019
…19307)

This PR is a more advanced form of the dirty-to-clean cacher (ethereum#18995),
where we reuse previous database write batches as datasets to uncache,
saving a dirty-trie-iteration and a dirty-trie-rlp-reencoding per block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants