-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
sys.setprofile doesn't do c_call
in all cases
#126056
Comments
This behavior is consistent with previous versions, it's not new. So this would be a feature request, instead of a bug. |
Normal profiling catches |
Well, not entirely. The documentation states
which means in C API, it can be safely casted to a So, supporting a type call, which is a breaking behavior, will actually break a lot of the profiler/debugger code out there which assumes the argument is a |
Perhaps could be solved by adding a new |
It would still be a breaking change. Not only on C API level, should we add a new type of event for I'm not saying this can't or shouldn't be done. I'm simply stating that this is not a trivial bug fix. This is a new feature request that could potentially break plenty of the existing code, no matter how you implement it, because it breaks some assumptions that have been there for 10 years. Therefore, we'd better have a really good reason to add it. |
The reason I encountered this was in a memory profiler: I use PyTrace_C_CALL to record and cache the latest line number, so that C code that releases the GIL and allocates can still record the the latest Python line number for that allocation. But e.g. More broadly, having certain code paths just be invisible to Python's profiling API is likely to hit other profilers based on these APIs. E.g. a C type constructor that does a lot of compute work will get assigned to the calling function and it will be difficult for profiler users to track down where exactly the slowness is. Given it's not in current Python I will have to fix things regardless of what you all decide about this issue. Some alternatives I'm considering:
|
Bug report
Bug description:
When run with Python 3.13 on Linux:
No mention of
mmap.mmap()
, perhaps because it's a constructor of a type object.(This is really an issue with the underlying C API,
PyTrace_C_CALL
is similarly not happening.)As someone doing profiling, this means that any code running inside C type constructors is invisible, which is problematic and means I'm going to have to change how one of my profilers works.
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: