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

add feature to profile just the block validation #17168

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Dec 26, 2023

This exposes what is actually going on while we validate blocks. Sometimes the block validation times are affected by other tasks that hog the CPU, blocking the main co-routine from being scheduled.

Purpose:

When understanding what's causing spikes in block validation times, having a profile focused only on the time of validating the block can be quite helpful, especially when pre_validation nor post_processing takes very long.

It can help identify co-routines that run for too long (i.e. perform expensive work in the main thread), hogging the scheduler and delaying other tasks.

Current Behavior:

The only available profiler is for the whole full node task.

New Behavior:

There's now also a profiler for just block validation. If the validation takes longer than 2 seconds, the profile is saved for later analysis.

Testing Notes:

Example profiles from main.

(parsing the SubEpochChallengeSegments is slow)

4712903

(serializing the weight proof is slow)
4712099

(parsing BlockRecord is slow)
4711558

(sleep(0.01) in a loop is slow)
4710525

(merkle root validation and BLS signatures can still be expensive)
4710347

(saving peers is slow. This caused an 11.9 seconds block validation)
4712916

(request_additions is slow)
4713077

@arvidn arvidn requested a review from a team as a code owner December 26, 2023 19:59
@arvidn arvidn added the Added Required label for PR that categorizes merge commit message as "Added" for changelog label Dec 26, 2023
Copy link

coveralls-official bot commented Dec 26, 2023

Pull Request Test Coverage Report for Build 7376667166

  • 11 of 11 (100.0%) changed or added relevant lines in 3 files are covered.
  • 16 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.09%) to 90.582%

Files with Coverage Reduction New Missed Lines %
tests/core/util/test_lockfile.py 1 91.09%
chia/rpc/rpc_server.py 2 88.05%
chia/full_node/full_node.py 3 85.1%
chia/plotters/madmax.py 3 48.77%
chia/daemon/server.py 7 86.48%
Totals Coverage Status
Change from base Build 7339581890: 0.09%
Covered Lines: 94086
Relevant Lines: 103839

💛 - Coveralls

@arvidn

This comment was marked as resolved.

…s actually going on while we validate blocks. Sometimes the block validation times are affected by other tasks that hog the CPU, blocking the main co-routine from being scheduled
@arvidn arvidn requested a review from wjblanke January 3, 2024 18:39
Copy link
Contributor

@wjblanke wjblanke left a comment

Choose a reason for hiding this comment

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

aok

@Starttoaster Starttoaster merged commit cc4e2d8 into main Jan 4, 2024
265 checks passed
@Starttoaster Starttoaster deleted the block-validation-profile branch January 4, 2024 18:53
mikehw pushed a commit to mikehw/chia-blockchain that referenced this pull request Jan 11, 2024
add feature to profile just the block validation. This exposes what is actually going on while we validate blocks. Sometimes the block validation times are affected by other tasks that hog the CPU, blocking the main co-routine from being scheduled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added Required label for PR that categorizes merge commit message as "Added" for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants