This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Patch to enable profiling of C functions called from python
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: nbastin Nosy List: loewis, nbastin
Priority: normal Keywords: patch

Created on 2004-03-21 15:25 by nbastin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
profile_patch.diff nbastin, 2004-03-23 22:47
Messages (7)
msg45613 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-21 15:25
This patch enables the profiling of C extension functions (and 
builtins) called via the CALL_FUNCTION opcode.  This also includes 
a modification to lib/profile.py to handle the new call type.  On my 
Powerbook 12" 867Mhz it incurs a 0.5% performance hit in the 
interpreter when profiling is not enabled.
msg45614 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-21 15:28
Logged In: YES 
user_id=430343

Note: this patch is fully backwards with profiler use - the data file is not 
changed in any way.  Also, any 3rd party profilers which would handle 
unknown event types will still continue to work (the standard python 
profiler isn't one of those, so the patch includes a fix for that as well).
msg45615 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-22 22:32
Logged In: YES 
user_id=430343

I'm working on a few modifications to this patch for documentation, as 
well as fixing the messages resulting from the fact that bdb is being 
handed events it doesn't understand.  I'll post that at some point before 
PyCon starts (tomorrow, probably).
msg45616 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-23 22:47
Logged In: YES 
user_id=430343

New patch attached to this post (and old patch removed).

This patch makes new events for all C-related calls, so old profilers
will still function properly if they ignore event types they don't
understand.  Also fixed bdb, tested hotshot, and changed the
documentation for the tracing API and the debugger event types
to document the new event types (and fixed some errors in the
names of the old events).  Also provides new data for test_profile
to compare against and modified test_profilehooks for minimal
understanding of c calls so it still passes.

regrtest passes all tests on MacOS X, and the non-profiling
performance hit is around 0.5%.
msg45617 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-23 23:25
Logged In: YES 
user_id=430343

BTW, I forgot to patch Misc/NEWS, so whoever commits
this should touch it.  Thanks.
msg45618 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-03-24 14:12
Logged In: YES 
user_id=21627

The patch is fine, with the following changes:
- use tabs instead of spaces for indentation in C source code
- add the Misc/NEWS change
msg45619 - (view) Author: Nick Bastin (nbastin) * (Python committer) Date: 2004-03-24 22:10
Logged In: YES 
user_id=430343

Files modified:

init.tex 1.16
libpdb.tex 1.39
pystate.h 2.27
bdb.py 1.44
profile.py 1.55
test_profilehooks.py 1.11
output/test_profile 1.3
NEWS 1.961
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40058
2004-03-21 15:25:00nbastincreate