Skip to content

accounts-db: read storages with direct I/O when generating the index - #15941

Merged
kskalski merged 2 commits into
anza-xyz:masterfrom
kskalski:ks/gen_index_dio
Oct 13, 2026
Merged

kskalski merged 2 commits into
anza-xyz:masterfrom
kskalski:ks/gen_index_dio

Conversation

@kskalski

@kskalski kskalski commented Oct 9, 2026 •

Copy link
Copy Markdown

Problem

Index generation reads every storage once through the page cache. On a mainnet fastboot the reads fill memory, so the growing index allocates through kernel direct reclaim for much of the scan.

Summary of Changes

  • read storages for index generation the way snapshot archiving does, with direct I/O when AccountsDbConfig::use_direct_io is set
  • set use_direct_io from the existing --no-accounts-db-snapshots-direct-io flag in the validator and ledger-tool, since both already validate the account paths for direct I/O
  • rename open_file_for_archive to open_file_for_bulk_read, since index generation now shares it with archiving

Testing

Mainnet fastboot restarts against the base commit (1.2 B accounts, two runs each) cut index_time from 37.8 s to 29.2 s and rebuild_bank from 40.8 s to 31.6 s, with identical indexed account counts.

  • master
master-profile
  • PR
pr-profile

@codecov-commenter

codecov-commenter commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.2%. Comparing base (7c79e75) to head (1a78e52).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15941   +/-   ##
=======================================
  Coverage    82.2%    82.2%           
=======================================
  Files         938      938           
  Lines      372938   372971   +33     
=======================================
+ Hits       306612   306658   +46     
+ Misses      66326    66313   -13     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kskalski
kskalski force-pushed the ks/gen_index_dio branch 4 times, most recently from 3e2090d to b450618 Compare October 12, 2026 01:22
Problem: Index generation reads every storage once through the page cache. On a mainnet fastboot the reads fill memory, so the growing index allocates through kernel direct reclaim for much of the scan.

Summary of Changes:
- read storages for index generation the way snapshot archiving does, with direct I/O when `AccountsDbConfig::use_direct_io` is set
- set `use_direct_io` from the existing `--no-accounts-db-snapshots-direct-io` flag in the validator and ledger-tool, since both already validate the account paths for direct I/O
- rename `open_file_for_archive` to `open_file_for_bulk_read`, since index generation now shares it with archiving

Testing: Mainnet fastboot restarts against the base commit (1.2 B accounts, two runs each) cut `index_time` from 37.8 s to 29.2 s and `rebuild_bank` from 40.8 s to 31.6 s, with identical indexed account counts.
@kskalski
kskalski marked this pull request as ready for review October 12, 2026 03:34
@kskalski
kskalski requested a review from a team as a code owner October 12, 2026 03:34
@brooksprumo

Copy link
Copy Markdown

Comment thread accounts-db/src/accounts_db.rs Resolved
Problem: Each index generation thread takes 64 storages at a time from the shared queue, so with fewer than about 64 storages per thread a few threads take all the storages while the others stay idle.

Summary of Changes: Compute the batch size from the number of storages and threads, capped at 64 to still bound the extra fds opened with direct I/O.

@brooksprumo brooksprumo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:shipit:

@kskalski
kskalski added this pull request to the merge queue Oct 13, 2026
Merged via the queue into anza-xyz:master with commit 2b9f930 Oct 13, 2026
49 checks passed
@kskalski
kskalski deleted the ks/gen_index_dio branch October 13, 2026 13:06
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