Skip to content
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

[Optimize] Skip the scheduled batch proposal if already proposing #3112

Merged
merged 2 commits into from
Mar 2, 2024

Conversation

ljedrz
Copy link
Collaborator

@ljedrz ljedrz commented Feb 21, 2024

If I'm not missing anything, a batch proposal can be triggered by a timed loop or round progression, and if we're already proposing a batch for a new round, it seems reasonable to me that we may skip the timed one. This would save some network traffic and CPU use for the validators.

I tested it locally and can see the skip happening from time to time, which means those attempts can currently overlap.

…gered one

Signed-off-by: ljedrz <ljedrz@gmail.com>
// A best-effort attempt to skip the scheduled batch proposal if
// round progression already triggered one.
if self_.propose_lock.try_lock().is_err() {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add some debug! message here for observing that there's an ongoing batch proposal attempt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be useful, but if my intuition is correct, such an occurrence could just be ignored (so a log would only increase verbosity); either way works for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in 44f498b

@raychu86
Copy link
Contributor

The propose_batch call a few lines after this new skip already has a propose_lock. So having this check will only ensure that we can continue with this loop (and perform extra self_.sync.is_synced() checks) instead of awaiting on the propose_batch call.

I believe this change is safe, but don't see that much of a difference in terms of resource optimizations. Let me know if I'm missing anything.

@ljedrz
Copy link
Collaborator Author

ljedrz commented Feb 29, 2024

@raychu86 you're right, it's nothing extreme, but it can avoid a duplicate proposal to be produced right after we produced one, which reduces CPU use and network traffic.

Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com>
@howardwu howardwu merged commit 682500d into AleoNet:mainnet Mar 2, 2024
23 of 24 checks passed
@howardwu howardwu changed the title Skip the scheduled batch proposal if already proposing [Optimize] Skip the scheduled batch proposal if already proposing Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants