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
[decoupled-execution] process_sync_req now tries to advance a buffer item to aggregated #9207
Conversation
if signed_item | ||
.commit_proof | ||
.commit_info() | ||
.match_ordered_only(ledger_info.commit_info()) |
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.
this should be full match?
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.
good point.
let executed_item = *executed_item_box; | ||
if executed_item | ||
.commit_info | ||
.match_ordered_only(ledger_info.commit_info()) |
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.
this too
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.
good point
.map(|eb| Arc::new(eb.clone())) | ||
.collect::<Vec<Arc<ExecutedBlock>>>(), | ||
); | ||
if link_eq(&cursor, &aggregated_item_cursor) { |
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'd prefer we break out the loop first then send the request, seems more readable
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.
in this function I want to easily distinguish successfully finding the item vs reaching the end of the list, so I let it send the request 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.
hmm, it's not possible to reach the end of the list without hitting the cursor right?
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.
Right now it is not possible. Just in case of a bug in the future.
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.
it seems more natural to have something like
while curson.is_some() {
if find {
break
}
}
assert!(!blocks_to_persist.is_empty());
send_request
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.
blocks_to_persist
collects the blocks before (including) the aggregated item. If it does not find the item, blocks_to_persist
contains all the blocks. I added a flag found
and moved the code outside the loop.
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.
oh, can't we just assert cursor.is_some() after the loop instead?
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.
We have to move out buffer_item anyway, so I just put it into an option and check if buffer_item has something. The code is already updated.
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 still feel we can simplify this code, but I guess I can try it myself after it gets merged
} | ||
unreachable!("Bad Aggregated Item Cursor: Item not found in the buffer."); |
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.
why this is unreachable?
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.
This function assumes the aggregated item exists in the buffer.
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.
it only break
after sending the request instead of return
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.
oops sorry I meant to return after sending the request
let (attempted_item, aggregated, matching) = | ||
buffer_item.try_advance_to_aggregated_with_ledger_info(ledger_info.clone()); | ||
set_elem(&cursor, attempted_item); | ||
if matching { |
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.
if aggregated is enough?
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.
there are three cases:
- not matched, not aggregated, we continue to the next iteration
- matched, not aggregated, we end the loop since we already found the item
- matched and aggregated, we call try_persisting to dequeue the items.
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 mean aggregated must be matched?
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, but they share a break statement. So I put it inside matching.
ad8d221
to
4b7a885
Compare
self.buffer.pop_front(); | ||
} | ||
|
||
if let Some(buffer_item) = found_item { |
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.
we can use expect here to avoid the if branch
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.
sounds good. I'll do this in the next PR.
.map(|eb| Arc::new(eb.clone())) | ||
.collect::<Vec<Arc<ExecutedBlock>>>(), | ||
); | ||
if link_eq(&cursor, &aggregated_item_cursor) { |
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 still feel we can simplify this code, but I guess I can try it myself after it gets merged
/land |
…item to aggregated. Pop a prefix of buffer items if found an aggregated item. Closes: #9207
💔 Test Failed - ci-test |
4b7a885
to
b7f44de
Compare
/land |
…item to aggregated. Pop a prefix of buffer items if found an aggregated item. Closes: diem#9207
Cluster Test Result
Repro cmd:
🎉 Land-blocking cluster test passed! 👌 |
b7f44de
to
3e33412
Compare
process_sync_request
now tries to advance a buffer item to aggregatedPop a prefix of buffer items if found an aggregated item.
Motivation
(Write your motivation for proposed changes here.)
Have you read the Contributing Guidelines on pull requests?
(Write your answer here.)
Test Plan
(Share your test plan here. If you changed code, please provide us with clear instructions for verifying that your changes work.)
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/diem/diem/tree/main/developers.diem.com, and link to your PR here.)
If targeting a release branch, please fill the below out as well