Skip to content

Conversation

mpage
Copy link
Contributor

@mpage mpage commented Jan 27, 2025

This PR adds support for profiling benchmarks using a perf-record hook. perf-record is enabled only during benchmark execution by using perf's support for control fifos.

For example, to collect stacks using DWARF debug information, one could run:

env PYPERF_PERF_RECORD_EXTRA_OPTS="--call-graph dwarf -e cycles:pp" \
       python -m pyperf timeit \
                    --debug-single-value \
                    --hook perf_record \
                    --inherit-environ PYPERF_PERF_RECORD_EXTRA_OPTS \
                    '1+1'

This should resolve #213.

@corona10 corona10 requested review from corona10 and mdboom February 5, 2025 17:56
@corona10
Copy link
Member

corona10 commented Feb 5, 2025

I will try to take a look at it by this weekend :)

Copy link
Collaborator

@mdboom mdboom left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. This is a tricky one to add a test and CI for -- I did test it locally and it "worked for me". I think for most purposes we can rely on bench_runner to ensure this doesn't bit rot.

@corona10
Copy link
Member

corona10 commented Feb 5, 2025

@mdboom
Copy link
Collaborator

mdboom commented Feb 25, 2025

@mpage: Are you working on addressing @corona10's comments? If not, just let me know and I can handle. I'd like to see this merged as well ;)

@mpage
Copy link
Contributor Author

mpage commented Feb 26, 2025

Ahh, thanks for the nudge. I've been heads down finishing up the LOAD_FAST optimization. I should be able to wrap this up on Friday.

@mpage
Copy link
Contributor Author

mpage commented Mar 1, 2025

@mdboom @corona10 - Sorry about the delay! I think I've addressed all the review comments and updated the docs.

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

lgtm

@corona10 corona10 merged commit 1fcdc2b into psf:main Mar 1, 2025
12 checks passed
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.

Support profiling benchmarks using perf-record

3 participants