-
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
ledger/blockstore: PerfSampleV2: num_non_vote_transactions #29404
ledger/blockstore: PerfSampleV2: num_non_vote_transactions #29404
Conversation
ledger/src/blockstore_meta.rs
Outdated
pub num_transactions: u64, | ||
pub num_non_vote_transactions: u64, |
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.
Trying to be as friendly to future us as possible, I'm thinking about the following sequence which does come up:
- Someone is running master or some branch that has this commit (ie inserting V2s)
- They run into an issue unrelated to this change that causes them to want to bisect (with the same ledger, maybe via
solana-ledger-tool verify
) - This person at some point ends up trying to run a commit older than the one this PR will introduce
- The older commit isn't aware of PerfSampleV1 & V2, only the original PerfSample struct which is 18 bytes (as is V1) and as such, will try to deserialize blockstore entries into the original struct
Given that we use the serialize / deserialize functions (and not the option), deserializing an instance of V2 (26 bytes) that was inserted in 1) above (ie with this commit) will not error in 4) as an original PerfSample, since the deserialize function allows trailing bytes by default (original has one less u64 so 8 trailing bytes).
Even though we won't get an error, the ordering will have changed so we'll be interpreting fields incorrectly. This can be avoided if we move the new field to the end of the struct. I realize this is pretty brittle, but it is better than doing nothing. All this being said, I struggle to see a scenario where we'd be debugging something of the sort and examining this column, but better to have one less possible foot-gun I guess.
Note: I'm pretty sure bincode serializes struct fields in the order specified, even if the compiler would want to rearrange things for better packing (ie multiple u16's in the same struct as a u64).
I was poking around bincode's GitHub and ended up deep enough down the rabbit hole to lead back to discussion on our GH in regards to a similar problem that this issue looks to solve. The below comment has a suggestion that might work nicely for us here (it ended up not working in the scenario where it was proposed, but it should work here): This is consistent with my last comment about making sure the new field is at the end of the struct. In any case, I think some of the commentary in referenced issue is relevant, and is worth consideration here. |
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.
Just one syntax suggestion and tiny nit
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.
Caught one typo. Otherwise, looks good to me!
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.
Just a couple of nitpicks / minor suggestions on my end, so I think good to go after those and Tyera's comments addressed
Pull request has been modified.
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, looks like just one bad keystroke. Also, nice on getting rid of explicit drop()
let (bank, highest_slot) = {
let forks = bank_forks.read().unwrap();
(forks.root_bank(), forks.highest_slot())
};
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.
Also, nice on getting rid of explicit
drop()
Fwiw, it would be nice if, in future, refactors like that code block were done in a separate commit from additions to make review a little easier. (But don't worry about changing this PR!)
This is where Gerrit would have been a much better tool ;) With GitHub I need to juggle multiple branches, making sure they are in sync. |
Store non-vote transaction counts that are now recorded by the banks into the `blockstore`. `SamplePerformanceService` now populates `PerfSampleV2` with counts from the banks.
Pull request has been modified.
Good point Tyera; I found the variables a little confusing so I made a request to change, but in general, agreed that it is better to break cleanup into its' own PR.
Yeah, unfortunately not a better way to do it with GitHub that I'm aware of. When I see a small cleanup task that can be carved out, I usually like to have to have it in master before my original PR (personal preference but extra overhead). But yeah, make a second branch / second PR, get that submitted and then rebase original branch on top. |
Yeah, I don't know of any way to use git to assign parts of the current changeset to separate commits, unless they are in separate files. I usually use interactive rebase and recreate the first sub-changeset. Works okay. |
Sad :(
Thanks for sharing. I'll try this approach next time.
I know now to split changes in a single file into a separate commit. But after I split changes into a separate commit, GitHub would not allow just this commit to be reviewed and approved. Gerrit, on the other hand, does not have a notion of PRs at all. If you do not care how changes are combined. |
Not ok with things being mixed together. Sometimes it takes a bit to retrain your brain to work in the github model. But it's possible and it's generally fine. Yes, I fully agree Gerrit is better. |
Problem
As part of work on #29159 we need to store "non-vote transaction counts" in the blockstore.
Summary of Changes
Store non-vote transaction counts that will be recorded by the banks into the
blockstore
.Part of work on #29159