Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Add accounts_data_len to Bank#21781

Merged
brooksprumo merged 1 commit intosolana-labs:masterfrom
brooksprumo:bank-accounts-data-len
Dec 11, 2021
Merged

Add accounts_data_len to Bank#21781
brooksprumo merged 1 commit intosolana-labs:masterfrom
brooksprumo:bank-accounts-data-len

Conversation

@brooksprumo
Copy link
Copy Markdown
Contributor

@brooksprumo brooksprumo commented Dec 10, 2021

Problem

To set a cap on the accounts data size, transaction processing needs to know about the current size of the accounts data. This falls to the bank, which doesn't currently know about the size of the accounts data.

Summary of Changes

Add a field to Bank for storing the current accounts data size.

Build on PR #21757
Related to Issue #21604

Comment thread runtime/src/bank.rs
Comment on lines +1195 to +1198
let total_accounts_stats = bank.get_total_accounts_stats().unwrap();
bank.accounts_data_len
.store(total_accounts_stats.data_len as u64, Release);
Copy link
Copy Markdown
Contributor Author

@brooksprumo brooksprumo Dec 10, 2021

Choose a reason for hiding this comment

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

I was/am worried where Bank::default_with_accounts() is called. I've only seen it in tests, and in those cases the accounts data len here is always zero, and the time the get_total_accounts_stats() takes to run is 50-100 us on my MBP. Let me know if this should be changed though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe we rename it to default_for_tests or something and make tests be explicit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see, Bank::default_with_accounts() is called by Bank::new_with_paths(), which is called by blockstore_processor when starting from Bank 0. So I'm going to leave the bank functions named the way they are. I feel pretty good, since starting from Bank 0 should have zero accounts (or very few), and the get_total_accounts_stats to get the accounts_data_len will be fast.

@brooksprumo brooksprumo marked this pull request as ready for review December 10, 2021 20:02
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 10, 2021

Codecov Report

Merging #21781 (4030507) into master (379e3ec) will increase coverage by 0.0%.
The diff coverage is 88.8%.

@@           Coverage Diff           @@
##           master   #21781   +/-   ##
=======================================
  Coverage    81.3%    81.3%           
=======================================
  Files         515      515           
  Lines      144019   144025    +6     
=======================================
+ Hits       117099   117123   +24     
+ Misses      26920    26902   -18     

jeffwashington
jeffwashington previously approved these changes Dec 11, 2021
Copy link
Copy Markdown
Contributor

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

I think I'm ok with this. Maybe rename the default function.

@brooksprumo brooksprumo force-pushed the bank-accounts-data-len branch from 890d6d6 to 4030507 Compare December 11, 2021 01:29
@mergify mergify Bot dismissed jeffwashington’s stale review December 11, 2021 01:30

Pull request has been modified.

@brooksprumo brooksprumo merged commit eeb97fe into solana-labs:master Dec 11, 2021
@brooksprumo brooksprumo deleted the bank-accounts-data-len branch December 11, 2021 15:34
mergify Bot pushed a commit that referenced this pull request Jan 4, 2022
mergify Bot added a commit that referenced this pull request Jan 5, 2022
(cherry picked from commit eeb97fe)

Co-authored-by: Brooks Prumo <brooks@solana.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants