Open
Conversation
SgtPooki
commented
Mar 11, 2024
Member
Author
SgtPooki
left a comment
There was a problem hiding this comment.
self review.. there are some TODOs in the code with questions
| } | ||
| } | ||
|
|
||
| async handleSizeForPut (key: Key, value: Uint8Array): Promise<void> { |
Member
Author
|
cc @wemeetagain because this should be able to solve the needs of ChainSafe/lodestar@unstable/packages/beacon-node/src/network/peers/datastore.ts?rgh-link-date=2023-10-19T14%3A35%3A02Z#L71 |
SgtPooki
commented
Mar 11, 2024
| * keys are added to the end of the array when added or updated | ||
| * keys are removed from the start of the array when evicted | ||
| * Note: size of keys is not tracked, so if you have large keys, you should | ||
| * increase the maxBytes limit accordingly |
Member
Author
There was a problem hiding this comment.
Suggested change
| * increase the maxBytes limit accordingly | |
| * decrease the maxBytes limit accordingly |
SgtPooki
commented
Mar 11, 2024
| */ | ||
| private readonly evictionOrder: Key[] = [] | ||
|
|
||
| constructor ({ maxBytes, store }: { maxBytes: number, store: T }, backingStore: T2) { |
Member
Author
There was a problem hiding this comment.
i'm not completely happy with these constructor args either...
SgtPooki
commented
Mar 11, 2024
| } | ||
| if (this.currentBytes + requiredSpace > this.maxBytes && this.evictionOrder.length > 0) { | ||
| log.trace('Evicting %d bytes from primary store to backing store', requiredSpace) | ||
| while (this.currentBytes + requiredSpace > this.maxBytes && this.evictionOrder.length > 0) { |
Member
Author
There was a problem hiding this comment.
we could probably be smarter here and use .batch()
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
partially addresses #287
tiered-limit-blockstore to come when we agree upon the final design
some of my thoughts are in #287, but i'm not completely happy with the name "tiered-limit".. maybe "buffered-datastore" or "front-cache-datastore"
The idea behind this though, is that folks can do various kinds of combinations with other datastores. Some ideas: