-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: add tiered-limit datastore #301
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self review.. there are some TODOs in the code with questions
} | ||
} | ||
|
||
async handleSizeForPut (key: Key, value: Uint8Array): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be private
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 |
* 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* increase the maxBytes limit accordingly | |
* decrease the maxBytes limit accordingly |
*/ | ||
private readonly evictionOrder: Key[] = [] | ||
|
||
constructor ({ maxBytes, store }: { maxBytes: number, store: T }, backingStore: T2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not completely happy with these constructor args either...
} | ||
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could probably be smarter here and use .batch()
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: