simplify bank drop calls#24142
Conversation
|
Some quick comments; I still need to review more carefully.
Yes, it's confusingly named currently. This code path was just recently changed to fix #23976 in PR #23999. So
I agree that setting the |
|
My reading of the code is that - it seems that |
brooksprumo
left a comment
There was a problem hiding this comment.
Ok, I'm on board with this change now. I think it's now safe since #23999 sets the bank drop callback on load, before any new banks are created or any bank refs are passed out.
I had some nits below, but otherwise looks good. Once the changes are in and the CI passes coverage, please re-request a review. Thanks!
| /// Purge a slot if it is not a root | ||
| /// Root slots cannot be purged | ||
| /// `is_from_abs` is true if the caller is the AccountsBackgroundService | ||
| pub fn purge_slot(&self, slot: Slot, bank_id: BankId, is_from_abs: bool) { | ||
| self.accounts_db.purge_slot(slot, bank_id, is_from_abs); | ||
| pub fn purge_slot(&self, slot: Slot, bank_id: BankId) { | ||
| self.accounts_db.purge_slot(slot, bank_id); | ||
| } |
There was a problem hiding this comment.
Just remove this whole function. I'll mark the caller next.
|
|
||
| /// This should only be called after the `Bank::drop()` runs in bank.rs, See BANK_DROP_SAFETY | ||
| /// comment below for more explanation. | ||
| /// `is_from_abs` is true if the caller is the AccountsBackgroundService |
There was a problem hiding this comment.
nit: Please remove this comment now that is_from_abs has been removed.
Co-authored-by: Brooks Prumo <brooks@prumo.org>
Co-authored-by: Brooks Prumo <brooks@prumo.org>
Co-authored-by: Brooks Prumo <brooks@prumo.org>
brooksprumo
left a comment
There was a problem hiding this comment.
This looks good to me. I think it'd probably be worthwhile to have another person approve as well; to make sure I didn't miss anything.
Codecov Report
@@ Coverage Diff @@
## master #24142 +/- ##
=========================================
- Coverage 81.8% 81.6% -0.2%
=========================================
Files 581 590 +9
Lines 158312 160999 +2687
=========================================
+ Hits 129518 131469 +1951
- Misses 28794 29530 +736 |
|
@carllin @jeffwashington Can you help to review this? Thanks! |
|
@carllin I think this needs to be you. |
|
The flag serves a few purposes I think which are still useful:
That being said, the |
|
OK. Close the pull request. Let's leave the code as it is. |
|
Reopen the pull request for more discussion. Ideally, the check shouldn't be on the purge_slot fn. It should be inside the drop_callback. Or maybe we could use the msb the bank_id to indicates that we are dropping (659af56)? This will limit that the range of bank_id will only be 63bit. |
Pull request has been modified.
Why can't we change the Bank struct? |
|
Line 1085 in 2e5042d In the comments, it is saying that serialization/deserialization are implemented elsewhere. I assume that Bank is embedded in some other serialized struct? |
I think it makes sense to leave the flag in the From my comment above: #24142 (comment), one of the purposes is |
|
what do you mean by |
|
It means that the |
|
Ok. Added back the bool param for |
* simplify bank drop calls * clippy: import * Update ledger/src/blockstore_processor.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> * Update runtime/src/accounts_background_service.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> * Update runtime/src/bank.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> * cleanup * format * use msb of bank_id to indicates that we are dropping * clippy * restore bank id * clippy * revert is-serialized_with_abs flag * assert * clippy * whitespace * fix bank drop callback check * more fix * remove msb dropping implementation * fix Co-authored-by: Brooks Prumo <brooks@prumo.org>
* simplify bank drop calls * clippy: import * Update ledger/src/blockstore_processor.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> * Update runtime/src/accounts_background_service.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> * Update runtime/src/bank.rs Co-authored-by: Brooks Prumo <brooks@prumo.org> * cleanup * format * use msb of bank_id to indicates that we are dropping * clippy * restore bank id * clippy * revert is-serialized_with_abs flag * assert * clippy * whitespace * fix bank drop callback check * more fix * remove msb dropping implementation * fix Co-authored-by: Brooks Prumo <brooks@prumo.org>
Problem
The extra parameter, is_from_abs in
purge_slotfunction is only used for assert. It seems unnecessary. Furthermore, it is also a bit confusing since caller from block_store also set it to true.is_bank_drop_callback_enabled flag seems also unnecessary since the call back is an Option. Besides, this flag is set in a callback create function, which seems not to be the right place. The right place should be at the caller, which installed the drop callback to the root bank.
Summary of Changes
simplify the bank drop calls.
Fixes #