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

blockstore: Reduce intermediate collects from multi_get() #4312

Merged
merged 11 commits into from
Jan 8, 2025

Conversation

steviez
Copy link

@steviez steviez commented Jan 7, 2025

Problem

The rocksdb multi_get() method allows us to fetch multiple values in a single rocksdb call. We currently return the results as a Vec by collecting item in LedgerColumn methods. But, we then immediately those Vec's, making the intermediate .collect() useless and wasteful.

Summary of Changes

  • Move key allocation outside of multi_get() methods so the keys live long enough
  • Make the multi_get() methods return impl Iterator ... and update call sites

@steviez steviez force-pushed the bstore_multi_get_iter branch from 6823bf4 to dc666ab Compare January 7, 2025 03:21
@steviez steviez force-pushed the bstore_multi_get_iter branch from dc666ab to ab16249 Compare January 7, 2025 03:30
Copy link
Author

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Decent amount of whitespace change in this PR - I tried to keep cargo fmt runs in their own commits so reviewing commit-by-commit and/or hiding whitespace might reduce the noise

ledger/src/blockstore_db.rs Show resolved Hide resolved
ledger/src/blockstore.rs Show resolved Hide resolved
ledger/src/blockstore_db.rs Show resolved Hide resolved
ledger/src/blockstore_db.rs Show resolved Hide resolved
Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

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

couple of questions. Looks like a nice improvement over all

ledger/src/blockstore.rs Outdated Show resolved Hide resolved
ledger/src/blockstore.rs Show resolved Hide resolved
ledger/src/blockstore.rs Outdated Show resolved Hide resolved
cpubot
cpubot previously approved these changes Jan 7, 2025
Copy link

@cpubot cpubot left a comment

Choose a reason for hiding this comment

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

LGTM, just a note about potentially collecting rather than Vec::with_capacity()

bw-solana
bw-solana previously approved these changes Jan 7, 2025
cpubot
cpubot previously approved these changes Jan 7, 2025
@steviez steviez dismissed stale reviews from cpubot and bw-solana via 2e3b85b January 7, 2025 23:10
@steviez steviez merged commit 4d5daab into anza-xyz:master Jan 8, 2025
40 checks passed
@steviez steviez deleted the bstore_multi_get_iter branch January 8, 2025 04:00
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.

3 participants