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

Enclose check_next_block Call with Debug Assertions for Validators #3383

Draft
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

kpandl
Copy link
Contributor

@kpandl kpandl commented Aug 23, 2024

Motivation

The check_next_block function incurs significant processing time, which contributes to increased block times. For validators participating in consensus, the checks performed by this function are redundant, as they are already handled elsewhere in the codebase. This PR encloses the check_next_block call within debug assertions (#[cfg(debug_assertions)]) to optimize performance and reduce block times in production environments.

Test Plan

Ran it locally. Todo: Further stress tests (load, syncing).

To verify that all checks remain adequately covered, you can find useful notes in this diff:

check_next_block.patch

@raychu86
Copy link
Contributor

What are the heavy parts of the check_next_block call?

The Transaction verification results should be cached already; are there other parts of the verification process that are costly? Maybe the db lookups?

@kpandl
Copy link
Contributor Author

kpandl commented Aug 26, 2024

Based on a flamegraph analysis, the most time-consuming operation within the check_next_block function is compute_finalize_root.

While there is potential to further optimize by caching, it seems worth investigating how we can skip check_next_block entirely to optimally reduce the block time, since other parts of the function may become bottlenecks with larger committee sizes.

Please note that we should run certain stress tests (load, syncing) before merging the PR.

@kpandl kpandl marked this pull request as draft September 11, 2024 18:08
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.

2 participants