python / cpython

The Python programming language
https://www.python.org
Other
63.11k stars 30.22k forks source link

Call stats are incorrect for tier 2 and maybe for tier 1 as well #118036

Open markshannon opened 6 months ago

markshannon commented 6 months ago

Bug report

Bug description:

The call stats for tier 2 differ significantly from tier 1, but it is not clear that the tier 1 call stats are correct either.

The main purpose of the call stats is to track the fraction of Python frames that are created with and without calls to PyEval_EvalDefault. However, the stats don't make that clear and may be incorrect.

Currently the table looks like this:

  Count Ratio
Calls to PyEval_EvalDefault 2,309,411,110 32.0%
Calls to Python functions inlined 4,908,275,087 68.0%
Calls via PyEval_EvalFrame (total) 2,309,411,110 32.0%
Calls via PyEval_EvalFrame (vector) 1,447,866,962 20.1%
Calls via PyEval_EvalFrame (generator) 861,544,148 11.9%
Calls via PyEval_EvalFrame (legacy) 4,418,464 0.1%
Calls via PyEval_EvalFrame (function vectorcall) 1,443,417,872 20.0%
Calls via PyEval_EvalFrame (build class) 30,626 0.0%
Calls via PyEval_EvalFrame (slot) 475,837,706 6.6%
Calls via PyEval_EvalFrame (function ex) 38,365,096 0.5%
Calls via PyEval_EvalFrame (api) 256,353,600 3.6%
Calls via PyEval_EvalFrame (method) 213,159,135 3.0%
Frame objects created 88,466,853 1.2%
Frames pushed 4,953,781,868 68.6%

Note that the numbers don't add up. The number of "frames pushed" is actually the total number of frames created. As it is function frames pushed, generator frames are not counted.

Frame objects created should be a fraction of "frames created". All other numbers should be a fraction of "frames pushed"

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

gvanrossum commented 6 months ago

Could you clarify which numbers you expect to add up?