Skip to content

Scans each storage only once when building accounts index#6745

Merged
brooksprumo merged 2 commits intoanza-xyz:masterfrom
brooksprumo:index/secondary
Jun 26, 2025
Merged

Scans each storage only once when building accounts index#6745
brooksprumo merged 2 commits intoanza-xyz:masterfrom
brooksprumo:index/secondary

Conversation

@brooksprumo
Copy link
Copy Markdown

@brooksprumo brooksprumo commented Jun 25, 2025

Problem

When building the accounts index, if secondary indexes are on, we scan each account storage file twice. This is bad, performance wise. The second scan is needed to get each account's data, which secondary indexes need.

We should switch on if secondary indexes are enabled or not, and then decide how to scan the storage. E.g. if secondary indexes are on, scan once with account data. If secondary indexes are off, scan once without account data.

Summary of Changes

Instead of scanning twice, only scan once! Pick the scan function depending on if secondary indexes are on or off.

@brooksprumo brooksprumo self-assigned this Jun 25, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.3%. Comparing base (b979967) to head (a929105).
⚠️ Report is 3054 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6745   +/-   ##
=======================================
  Coverage    83.3%    83.3%           
=======================================
  Files         852      852           
  Lines      378005   378020   +15     
=======================================
+ Hits       315220   315251   +31     
+ Misses      62785    62769   -16     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread accounts-db/src/accounts_db.rs Outdated
@brooksprumo brooksprumo marked this pull request as ready for review June 26, 2025 17:14
@brooksprumo brooksprumo requested review from HaoranYi and roryharr June 26, 2025 17:40
Comment thread accounts-db/src/accounts_db.rs
Comment thread accounts-db/src/accounts_db.rs
Copy link
Copy Markdown

@HaoranYi HaoranYi left a comment

Choose a reason for hiding this comment

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

nice find.
lgtm.

@brooksprumo brooksprumo merged commit cfa4c2c into anza-xyz:master Jun 26, 2025
28 checks passed
@brooksprumo brooksprumo deleted the index/secondary branch June 26, 2025 21:22
@mergify
Copy link
Copy Markdown

mergify Bot commented Jul 9, 2025

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

mergify Bot pushed a commit that referenced this pull request Jul 9, 2025
brooksprumo added a commit that referenced this pull request Jul 10, 2025
…port of #6745) (#6896)

* Scans each storage only once when building accounts index (#6745)

(cherry picked from commit cfa4c2c)

* resolves missing (removed) fields

---------

Co-authored-by: Brooks <brooks@anza.xyz>
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.

5 participants