This repository was archived by the owner on Dec 17, 2024. It is now read-only.
Multi-dag LRU caching in Light, support per-instance caches#81
Merged
obscuren merged 1 commit intoethereum:masterfrom Feb 24, 2016
karalabe:perinstance-vefitication-cache
Merged
Multi-dag LRU caching in Light, support per-instance caches#81obscuren merged 1 commit intoethereum:masterfrom karalabe:perinstance-vefitication-cache
obscuren merged 1 commit intoethereum:masterfrom
karalabe:perinstance-vefitication-cache
Conversation
| // TODO: keep multiple caches. | ||
| test bool // if set use a smaller cache size | ||
| mu sync.Mutex // protects the per-epoch map of DAGs | ||
| dags map[uint64]*cache // currently cached verification DAGs |
Contributor
There was a problem hiding this comment.
Can we rename this to "caches"? Ethash terminology distinguishes cache (for verification) and DAG (for mining).
Member
Author
|
@fjl PTAL |
Contributor
|
👍 |
Contributor
|
👍 |
obscuren
added a commit
that referenced
this pull request
Feb 24, 2016
Multi-dag LRU caching in Light, support per-instance caches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ethash in its current state contains two issues, the combination of which makes epoch transitions very expensive:
This PR fixes both of these scenarios, while maintaining the existing feature set:
Lightstructure was expanded with a simple LRU cache implementation, that accumulates a maximum of 3 verification DAGs before starting to evict old ones (least recently retrieved). Although during normal operation 2 DAGs should suffice, the reason the 3rd one was inserted is to avoid cache trashing when older blocks also circulate the network.Ethashinstances to be independent of each other, so the plainethash.Newmethod was fixed to use its ownLightstruct. However, to keep the ability to reuse caches during tests, I've added aNewSharedmethod to ethash, which is essentially the oldNew, reusing the same shared Light cache.