-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
[3.12] cProfile counts 0 primitive calls for builtins.exec in certain scenario #106152
Comments
I'll take a look, it's probably related to either my changes to use PEP 669 for cProfile or PEP 669 itself. |
For the second example, that's the only output from cProfile? Do you have a demo on that one? It seems like an easier example to follow up. |
Sorry, it was truncated. I added an ellipsis. Here is the full output. To reproduce: python3.12 -m pip install git+https://github.com/pylint-dev/pylint@8aa0d72ae1d5e3df55abdf5dea644cff1318fd15
python3.12 -m pip install git+https://github.com/pylint-dev/astroid@fef38f2dd474b0dacd1dda3f15abbf61eb0e9a71
echo "from pylint.lint import Run;Run(['astroid', '--disable=duplicate-code'])" > script.py
python3.12 -m cProfile script.py > out 3.12 result
|
(PS - the name collision between typing.py and |
The reason for this is that I forgot the PY_THROW event when I was trying to restructure cProfile, which caused a missing start entry for any In your second case, there's probably a generator that's doing this for multiple times which caused a lot of missing counts. I've already submitted a PR and it's a simple fix. This should be merged back to 3.12 in the next release. |
Thanks for the brisk diagnosis and fix! |
(cherry picked from commit cea9d4e) Co-authored-by: Tian Gao <[email protected]>
GH-106152: Add PY_THROW event to cProfile (GH-106161) (cherry picked from commit cea9d4e) Co-authored-by: Tian Gao <[email protected]>
Bug report
In 3.12, cProfile can count 0 primitive calls and miscalculate cumulative time in the following scenario.
For this layout:
And the file contents:
script.py
project/typing.py
I observe this behavior difference with
python3 -m cProfile script.py
:3.11.2
3.12.0b3
Notice the division by zero causing a missing
percall
stat for exec.This means that in more substantial examples, the profiler will omit a significant portion of the relevant cumulative time. See this output for a 14.286 second script, I only have access to a cumtime for 0.800:
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: