Skip to content

Implementing an Account Storage Reader to stream Account Storages during snapshots and testing#5950

Merged
roryharr merged 17 commits intoanza-xyz:masterfrom
roryharr:implement_account_storage_reader
May 27, 2025
Merged

Implementing an Account Storage Reader to stream Account Storages during snapshots and testing#5950
roryharr merged 17 commits intoanza-xyz:masterfrom
roryharr:implement_account_storage_reader

Conversation

@roryharr
Copy link
Copy Markdown

Problem

Account archive internals are exposed to the runtime library
Dead accounts need to be filtered when being written to storage during snapshot.

Summary of Changes

Implemented an account storage reader to convert an account storage into a class that supports the trait read.
Modified paths that stream account storages to use the new type.

Fixes #

Comment thread accounts-db/src/accounts_db.rs Outdated
@roryharr
Copy link
Copy Markdown
Author

roryharr commented Apr 24, 2025

First Graph: Just this change (no dead accounts)
image

Snapshot time, orange and purple are just reference machines.
Blue is the dev box that is running both new snapshot code and old snapshot code.
At 22:00 the old snapshot code is running. At 3:00, 9:00 and 14:00 the new snapshot code is running. No Performance Difference.

Second Graph: Dead_Accounts code transitioning from old method of filter to new method of filtering
image
Transition from old method to new method occurs ~1830. Snapshot time goes from 1.70b us (~28min) to 1.16b us (~20min)

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 97.36842% with 9 lines in your changes missing coverage. Please review.

Project coverage is 82.9%. Comparing base (c27b011) to head (8b3c3d8).
Report is 86 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #5950    +/-   ##
========================================
  Coverage    82.9%    82.9%            
========================================
  Files         842      843     +1     
  Lines      377804   378161   +357     
========================================
+ Hits       313223   313637   +414     
+ Misses      64581    64524    -57     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roryharr roryharr changed the title Implementing an Account Storage Reader to stream Account Storages durng snapshots and testing Implementing an Account Storage Reader to stream Account Storages during snapshots and testing Apr 24, 2025
Comment thread runtime/src/serde_snapshot/tests.rs
@roryharr roryharr force-pushed the implement_account_storage_reader branch 2 times, most recently from 6495364 to 0a1b346 Compare April 25, 2025 18:59
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread runtime/src/snapshot_utils.rs Outdated
Comment thread runtime/src/serde_snapshot/tests.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/accounts_db.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs
@roryharr roryharr requested a review from brooksprumo April 29, 2025 06:54
@roryharr roryharr marked this pull request as ready for review April 29, 2025 06:54
Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Now that this PR has dead accounts stuff in it, the PR is getting quite involved. It may actually make sense to do the AccountStorageReader on its own, without any dead accounts stuff. (I haven't tried implementing that, so not sure exactly what it looks like though.)

Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/accounts_db.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
roryharr added 6 commits May 9, 2025 10:44
@roryharr roryharr force-pushed the implement_account_storage_reader branch from f80903e to 6b049cb Compare May 9, 2025 21:39
@roryharr roryharr requested a review from brooksprumo May 12, 2025 17:27
Comment thread accounts-db/src/accounts_db.rs Outdated
Comment thread accounts-db/src/accounts_db.rs Outdated
Comment thread accounts-db/src/accounts_db.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs
@brooksprumo brooksprumo self-requested a review May 13, 2025 15:10
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
@brooksprumo brooksprumo self-requested a review May 13, 2025 17:35
 Fixed reopen test hook to use new reference
Comment thread accounts-db/src/account_storage_reader.rs
@roryharr roryharr force-pushed the implement_account_storage_reader branch from 5bc04a6 to dad87e7 Compare May 13, 2025 22:48
@roryharr
Copy link
Copy Markdown
Author

Now that this PR has dead accounts stuff in it, the PR is getting quite involved. It may actually make sense to do the AccountStorageReader on its own, without any dead accounts stuff. (I haven't tried implementing that, so not sure exactly what it looks like though.)

I had missed this comment at the time.
The reason to add the dead accounts stuff is that this was largely untestable without it and the intent was unclear...

Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

I need to do another pass over the tests, but I think this looks good.

Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
@brooksprumo brooksprumo self-requested a review May 16, 2025 19:29
Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Tests are nicely done!

Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
@brooksprumo
Copy link
Copy Markdown

Also, how's the perf of this code? Does it impact snapshot at all, given that we aren't populating the obsolete accounts yet?

@roryharr
Copy link
Copy Markdown
Author

Also, how's the perf of this code? Does it impact snapshot at all, given that we aren't populating the obsolete accounts yet?

I'll get a re-run today with no dead accounts. Previously when I tested it it had no impact on perf without dead accounts, and actually improved things slightly with lots of dead accounts due to saving less data.

Using randomly generated seeds for testing. Logging seeds for reproduciability
Updated test to ensure last account being invalidated is always one of the test scenarios
@roryharr
Copy link
Copy Markdown
Author

Also, how's the perf of this code? Does it impact snapshot at all, given that we aren't populating the obsolete accounts yet?

I'll get a re-run today with no dead accounts. Previously when I tested it it had no impact on perf without dead accounts, and actually improved things slightly with lots of dead accounts due to saving less data.

Reconfirmed, no performance degredation

@roryharr roryharr requested a review from brooksprumo May 24, 2025 00:41
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Comment thread accounts-db/src/account_storage_reader.rs Outdated
Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

:shipit:

Great work!

@roryharr roryharr merged commit 060ff07 into anza-xyz:master May 27, 2025
47 checks passed
mircea-c pushed a commit to mircea-c/agave that referenced this pull request Jun 12, 2025
…ing snapshots and testing (anza-xyz#5950)

* Implementing an Account Storage Reader to stream Account Storages during snapshots and testing

This will be used with the obsolete account feature to remove obsolete entires during snapshots.
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