Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit - maybe keep the comment? When I first looked at this code, i thought why collect here, iterator should be enough; then the comment points out it also computes local variables. So in that sense, it's useful; (or refactor Ln 339-340 out)
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.
Fair, my thinking was that with your changes in place, we do explicitly use the
tx_costs
later on. So even tho we are updating variables as we iterate through, we are going to explicitly use the collected vector as wellThere 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.
Gotcha, think my code below can use mapped iterators, doesn't really need vec<Tx_cost> being collected first. But I can see now that comments can be redundant here. No problem to remove it. Can do refactor in other time.
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.
CostModel::calculate_cost()
returns aTransactionCost
that has non-trivial members (namely thatVec<Pubkey>
).solana/runtime/src/cost_model.rs
Lines 31 to 40 in 2ba7327
Once your newly added feature becomes active, we might iterate through
tx_costs
(the Vec that results from thecollect()
) twice. Heresolana/ledger/src/blockstore_processor.rs
Line 350 in 2ba7327
and here:
solana/ledger/src/blockstore_processor.rs
Lines 364 to 365 in 2ba7327
If we skip the
collect()
, we would have to calculate / allocate aTransactionCost
during these two iterations, something like the below right?The implementation of
CostModel::calculate_cost()
looks non-trivial enough on the surface that it seems avoiding this might be preferable.In case I'm mistaken and there would be merit to the refactor, agreed that separating into separate PR is the move so I'm going to proceed with this one.