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
gh-115178: Add Counts of UOp Sequences to pystats #115181
base: main
Are you sure you want to change the base?
Conversation
Make optimization_stats.opcode an array of pointers to UOpStats objects, instead of a member array. Add a *next_stats[512] field to the UOpStats struct Add _init_pystats function to initialize these new member structs Call _init_pystats inside _PyConfig_Write
Add print_uop_sequence function to specialize.c to output stored chains of uops
Sets the maximum depth of UOP sequences to track. Defaults to 2.
Once again this seems to have automatically requested reviews from a bunch of Code Owners... not sure if that's due to the merge from Main or from touching |
I think your merge from main caught a bunch of unrelated changes (look at the diff of the PR in the files tab). |
This usually does the trick: $ git switch <feature-branch>
$ # hack away
$ git commit
$ git switch main
$ git pull # <= make sure main is up to date
$ git switch -
$ git merge --no-ff main -m "Sync with main" |
@JeffersGlass, here's a recipe for fixing this: $ git switch uop-sequence-count
$ git revert 03db7a5e950639cbbaea38ad4521f55ab39b1495
$ git switch main
$ git pull
$ git switch -
$ git merge --no-ff main See also: |
This reverts commit 03db7a5.
Thank you both! @erlend-aasland your fix recipe worked a treat - I will be more careful about merging from main/pushing 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.
A couple of minor issues, but looks good in general.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Thank you for the corrections. I have made the requested changes; please review again. |
Adds the ability to track pairs, triples, and longer sequences of UOps to the
pystats
statistics.Currently, this only counts these statistics for the non-JIT tier 2 interpreter. I intend to include tracking in the JIT in a follow-up PR.
To try it out, run:
./configure --enable-pystats ./make mkdir /tmp/py_stats PYTHON_UOPS=1 ./python -X pystats -c $'x = 0\nfor i in range(1000):\n x+=i'
The output file at
/tmp/py_stats/???.txt
will contain a new section with UOp Sequence counts:Tools/scripts/summarize_stats.py
has also been expanded to encompass these new stats, with a new section:Counts for top 100 UOp Sequences of Length 2
Finally, a new environment variable,
PYTHONSTATS_UOPDEPTH
can be set to any integer to record sequences of length longer than two. For example:PYTHONSTATS_UOPDEPTH=4 PYTHON_UOPS=1 ./python -X pystats -c 'x = 0; for i in range(1000): x+=i
Yields:
Counts for top 100 UOp Sequences of Length 2
Counts for top 100 UOp Sequences of Length 3
Counts for top 100 UOp Sequences of Length 4
pystats
 #115178EDIT: I see this has automatically requested a review from a huge number of people. This is my first time submitting a PR to CPython - please do forgive me if I've goofed this process up somehow.
ð Documentation preview ð: https://cpython-previews--115181.org.readthedocs.build/