-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
allow test feature to skip rewrites #33851
Conversation
Codecov Report
@@ Coverage Diff @@
## master #33851 +/- ##
=========================================
- Coverage 81.9% 81.8% -0.1%
=========================================
Files 809 809
Lines 217717 217761 +44
=========================================
- Hits 178345 178329 -16
- Misses 39372 39432 +60 |
@jeffwashington can you take a look? thanks! |
runtime/src/serde_snapshot/tests.rs
Outdated
@@ -764,7 +768,7 @@ mod serde_snapshot_tests { | |||
// F: Finally, make Step A cleanable | |||
current_slot += 1; | |||
accounts.store_for_tests(current_slot, &[(&pubkey2, &account)]); | |||
accounts.calculate_accounts_delta_hash(current_slot); | |||
accounts.calculate_accounts_delta_hash(current_slot, Vec::default()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like we should probably make a calculate_accounts_delta_hash_with_skips
fn that takes the Vec and leave the signature of calculate_accounts_delta_hash
the same.
I should've done that initially. That would remove all this test noise. Once all features are activated, we'll be removing this arg and all these tests would just have to go back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. updated.
validator/src/cli.rs
Outdated
.arg( | ||
Arg::with_name("accounts_db_test_skip_rewrites_but_include_in_bank_hash") | ||
.long("accounts-db-test-skip-rewrites-but-include-in-bank-hash") | ||
.help("Debug option to skip rewrites for rent exempted accounts but still added them in bank delta hash calculation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rent exempt
. Remove ed
add them
. Remove ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes updated.
validator/src/cli.rs
Outdated
@@ -1194,6 +1194,12 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> { | |||
.help("Debug option to scan all append vecs and verify account index refcounts prior to clean") | |||
.hidden(hidden_unless_forced()) | |||
) | |||
.arg( | |||
Arg::with_name("accounts_db_test_skip_rewrites_but_include_in_bank_hash") | |||
.long("accounts-db-test-skip-rewrites-but-include-in-bank-hash") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my words here are so verbose. @brooksprumo or @HaoranYi do you have any better ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just accounts-db-test-skip-rewrites
? Since it's testing-only and hidden, it really only needs to make sense to us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. updated.
@@ -1243,7 +1243,7 @@ pub enum ZeroLamportAccounts { | |||
|
|||
/// Hash of an account | |||
#[repr(transparent)] | |||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Pod, Zeroable)] | |||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Pod, Zeroable, AbiExample)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is caused by the addition of the rewrites on Bank
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah.
I think a read is going to run every slot, right?Sounds like a mutex is better performance?Sent from my phone.On Oct 25, 2023, at 8:57 PM, Brooks ***@***.***> wrote:
@brooksprumo commented on this pull request.
In runtime/src/bank.rs:
@@ -816,6 +819,10 @@ pub struct Bank {
/// The change to accounts data size in this Bank, due to off-chain events (i.e. rent collection)
accounts_data_size_delta_off_chain: AtomicI64,
+ /// until the skipped rewrites feature is activated, it is possible to skip rewrites and still include
+ /// the account hash of the accounts that would have been rewritten as bank hash expects.
+ skipped_rewrites: RwLock<Vec<(Pubkey, AccountHash)>>,
This confuses me. I don't understand why we would use RwLock over Mutex. Without a read-heavy workload, RwLock will be strictly worse than a Mutex.
I understand this is test code, but the change to a Mutex is very minimal. Any I missing something?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
There are no read locks in the current impl, only write locks. |
There seems to be a bug in When calling this fn, it has the side effect of clearing A fix could be as follows - do not clear WDYT?
|
The two places that call I think we can ignore these use cases. There will only be interesting info in |
I was considering this a read, but you are right, it is technically a write: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Problem
When the feature to disable rewrites during rent collection is enabled, rent exempt accounts will not be rewritten during rent collection. And, consensus will not expect those accounts to be rewritten.
However, prior to that feature being activated, it is now possible for a validator to avoid rewrites (and improve performance), while still creating compatible bank hashes.
Summary of Changes
With a test option, during rent collection, do not do rewrites on rent exempt accounts. But, include the hashes into the bank hash's accounts delta hash so the validator remains compatible with consensus.
This allows us to test the long term effects of eliminating rewrites.
Fixes #