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

feat: add tiered-limit datastore #301

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Mar 11, 2024

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:

  1. never store more than X memory = memoryDataStore + blackholeDatastore
  2. have a cache in front of various other stores = memoryDatastore + tieredDatastore (to s3, google drive, and/or filesystem)
  3. have a filesystem cache in front of s3 = datastore-fs + datastore-s3
  4. combination of memory + file store backing to s3 = tiered-limit(memory + tieredLimit(fs + s3))

Copy link
Member Author

@SgtPooki SgtPooki left a 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

packages/datastore-core/src/tiered-limit.ts Outdated Show resolved Hide resolved
}
}

async handleSizeForPut (key: Key, value: Uint8Array): Promise<void> {
Copy link
Member Author

Choose a reason for hiding this comment

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

should be private

@SgtPooki
Copy link
Member Author

* 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
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
* increase the maxBytes limit accordingly
* decrease the maxBytes limit accordingly

*/
private readonly evictionOrder: Key[] = []

constructor ({ maxBytes, store }: { maxBytes: number, store: T }, backingStore: T2) {
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'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) {
Copy link
Member Author

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()

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.

1 participant