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

0. change(db): Use Ribbon filters for database index lookups #4040

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Apr 5, 2022

Motivation

  1. We need Zebra to sync faster for the cached state lightwalletd tests.
  2. We want to speed up Zebra's tests, and the slowest tests are sync tests.
  3. This might help with locking bugs.

Using Ribbon filters for index lookups makes it about 7% faster. (Ribbon filters are like bloom filters.)

Specifications

RocksDB can do lookups using a Ribbon filter, which can improve read performance:
https://docs.rs/rocksdb/latest/rocksdb/struct.BlockBasedOptions.html#method.set_ribbon_filter

See also:
https://zhangyuchi.gitbooks.io/rocksdbbook/content/RocksDB-Tuning-Guide.html

Solution

  • Use a Ribbon filter for database queries

This change doesn't require a database version increment, but it won't have the full performance impact until the database is rebuilt. (I tested locally, and the cached state test should also check this.)

Performance

I ran a full sync test to check performance:

It finished in 5h43m, compared with most syncs that are around 97% - 99% at 6h.
That's around 7% faster.

(The test was after the lightwalletd database changes, but it should also be faster before them.)

Review

Anyone can review this PR.

I'd like to merge this PR before we merge any more database changes, to make merging them faster.

Reviewer Checklist

  • Code makes sense
  • Existing Tests Pass
  • Sync is faster

Follow Up Tasks

Try a database format upgrade with these changes:

@teor2345 teor2345 changed the base branch from main to db-utxo-by-addr April 5, 2022 05:53
@teor2345 teor2345 self-assigned this Apr 5, 2022
@teor2345 teor2345 added C-enhancement Category: This is an improvement P-High 🔥 A-state Area: State / database changes do-not-merge Tells Mergify not to merge this PR lightwalletd any work associated with lightwalletd labels Apr 5, 2022
Ribbon filters are like Bloom filters, but more efficient.
@teor2345 teor2345 force-pushed the rocksdb-ribbon-filter branch from 715f868 to 95d8c67 Compare April 5, 2022 19:58
@teor2345 teor2345 changed the title change(db): Use ribbon filters for database index lookups change(db): Use Ribbon filters for database index lookups Apr 5, 2022
@teor2345 teor2345 changed the base branch from db-utxo-by-addr to main April 5, 2022 20:03
@teor2345 teor2345 marked this pull request as ready for review April 5, 2022 20:09
@teor2345 teor2345 requested a review from a team as a code owner April 5, 2022 20:09
@teor2345 teor2345 requested review from dconnolly and removed request for a team April 5, 2022 20:09
@teor2345 teor2345 removed the do-not-merge Tells Mergify not to merge this PR label Apr 5, 2022
@teor2345 teor2345 changed the title change(db): Use Ribbon filters for database index lookups 0. change(db): Use Ribbon filters for database index lookups Apr 5, 2022
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

Looks good! I'm wondering why 9.9 was chosen, but I'll go ahead with this to unblock the rest

mergify bot added a commit that referenced this pull request Apr 6, 2022
@teor2345
Copy link
Contributor Author

teor2345 commented Apr 6, 2022

macOS timed out fetching the Zcash parameters

@teor2345
Copy link
Contributor Author

teor2345 commented Apr 6, 2022

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Apr 6, 2022

refresh

✅ Pull request refreshed

mergify bot added a commit that referenced this pull request Apr 6, 2022
mergify bot added a commit that referenced this pull request Apr 6, 2022
@mergify mergify bot merged commit 7f351ab into main Apr 7, 2022
@mergify mergify bot deleted the rocksdb-ribbon-filter branch April 7, 2022 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-state Area: State / database changes C-enhancement Category: This is an improvement lightwalletd any work associated with lightwalletd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants