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

Don't load all of about-self into memory at startup #183

Open
staltz opened this issue Feb 16, 2021 · 0 comments
Open

Don't load all of about-self into memory at startup #183

staltz opened this issue Feb 16, 2021 · 0 comments
Labels
enhancement 🌱 New feature or request

Comments

@staltz
Copy link
Member

staltz commented Feb 16, 2021

This is an idea that concerns about-self, but in general applies to any leveldb index where each KV is a reduced state of somehow (e.g. about-self, ssb-friends, etc).

We need to apply processRecord on the previous state, so that's why we load all the states on startup time. But this costs almost 1sec during startup. 1 second times N "state-sensitive indexes" is N seconds.

Alternatives:

  • Load all states at startup time
    • This is what we currently do
    • Good for cases when there will be tons of processRecords called in succession, e.g. initial indexing
    • Bad for cases where the index is large and there won't be many processRecords afterwards, e.g. opening up the SSB app every day
  • Load each state just-in-time
    • Such as loading it inside processRecord, right before pushing to the batch array
    • Good for cases when there are few processRecord calls, e.g. every day SSB usage
    • Bad for initial indexing
  • Load up everything as soon as we detect lots of processRecord calls
    • Otherwise use the JIT technique
    • Might be a compromise, but seems tricky to implement, and there could be corner cases we don't see yet

Overall the question is how to load and update indexes which are state sensitive.

@staltz staltz added the enhancement 🌱 New feature or request label Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌱 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant