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
Add Systemtap/DTrace probes #48361
Comments
It would be great if the main Python distribution supported DTrace on I've attached a patch against 2.6 that instruments function calls. It's It is imperfect because I wasn't sure how to do the equivalent of IFDEF |
At one point we were told Apple would try to backport their dtrace |
It appears that Apple has dtracified their Python exeutable in Leopard. |
They have released the changes, that's what my patch (attached to the It's working, it just needs to be cleaned up (it will fail, I believe, You can use it now against 2.6 and probably with very few changes |
Brett> They have released the changes, that's what my patch (attached to I see the reference to Apple in your original post, but can't find anything At this point Jeff's code does a fair bit more than simply tracing the
I took care of the configure.in/Makefile.pre.in stuff today. The intent is
We are using 2.4 at work and it works there. I'm fairly certain we should (I still need to get approval to release it, but I don't think that will be Skip |
On Wed, Nov 12, 2008 at 9:31 PM, Skip Montanaro <report@bugs.python.org> wrote:
http://www.opensource.apple.com/darwinsource/10.5.5/python-30.1.2/ That isn't Python 3.0, that's what I guess they call Python "Apple That's where my patch comes from, it's just changing the .ed scripts
Sun has released a patch against DTrace that probes more than just I couldn't figure out why it broke the compile on OS X though, and There's another problem (I think) with DTrace probes ... if the Apple |
Brett> http://www.opensource.apple.com/darwinsource/10.5.5/python-30.1.2/ Thanks for the pointers. I'll work on getting a uniform patch which
Yeah, that would suck. It would be nice if they could agree on a common set Skip |
On Thu, Nov 13, 2008 at 08:05, Skip Montanaro <report@bugs.python.org> wrote:
Obviously Ronald is the Apple insider to talk to. If you want Sun, you |
And courtesy of Philip Jenvey, here I am. I would *really* like to work to help make this happen. Laszlo Peter http://src.opensolaris.org/source/xref/jds/spec-files/trunk/patches/Python25-07-dtrace.diff These patches include John Levon's ustack provider, which if you care I've also had some conversations with people at Apple, and they have I'd love to have a discussion about DTrace probe futures for CPython -- |
I'm the python package maintainer at Sun. |
So I completely dropped the ball on this. It appears we have some |
On Jan 22, 2009, at 1:35 PM, Skip Montanaro wrote:
Great. Actually the latest version of the patch is this one: <http://src.opensolaris.org/source/xref/jds/spec-files/trunk/patches/Python26-07-dtrace.diff Ted |
After applying the patch and reconfiguring I get compilation errors in |
me> I get an error later running dtrace which I have yet to investigate. Apple's dtrace program doesn't support the -G flag. When I remove it from
I tried adding "sudo" to the dtrace command. Then it prompts for my
I'm not sure what to do at this point. I'm not really a dtrace person. Skip |
Please see here for discussion about the -G flag on OS X: If I read it correctly, on OS X, you will need to use -h Unfortunately, this means that the makefile will have to |
Laca> Please see here for discussion about the -G flag on OS X:
We can worm around that using configure. Thanks for the reference. That |
Here's a patch against the current trunk (2.7) which compiles on my Mac. It The existing test cases pass on Apple except for one case in test_sys which There are as yet no new dtrace test cases so I can't confirm that the added |
I tried building this on my Mac and got this; ar cr libpython2.7.a Python/_warnings.o Python/Python-ast.o Python/ my configure line was: ./configure --enable-framework --enable-toolbox-glue --with-threads -- On Jan 25, 2009, at 2:00 PM, Skip Montanaro wrote:
|
Ted> I tried building this on my Mac and got this; Forgive me if I'm preaching to the choir here. Did you run autoconf or autoreconf after applying the patch? If not, Skip |
I didn't run auto(re)conf. After I did that, all was well. However, cc1: warning: /dev/fd/5 is shorter than expected The basic function entry/exit probes appear to be working. John +nosy'ed himself, so perhaps he'll have some insight? On Jan 27, 2009, at 3:39 PM, Skip Montanaro wrote:
|
I haven't seen "shorter than expected" message before, sounds like a Mac As for never getting any probes out, this is where it gets fun. I don't even know how the Apple guys debug this sort of thing, but |
Skip, it doesn't appear that the ustack helper is getting incorporated Include/phelper.h: $(srcdir)/Include/phelper.d I *think* it should be something along these lines: Include/phelper.h: $(srcdir)/Include/phelper.d There are some static functions in the standard system headers that get Even if that would work, phelper.h is not #included anywhere. I'm not
really sure where it needs to go. On Solaris, the object file gets
linked in, but on OS X, you don't generate an object file; you just
#include the .h. Somewhere. I'm guessing where the pydtrace.h is
currently, but I don't really know. John, do you have any insights? Also, s/DTRADEHDRS/DTRACEHDRS/ |
Got a bit farther. Adding this stanza to the top of phelper.d gets past #ifdef __APPLE__
#define _SYS_TIME_H_
#define _SYS_SELECT_H_
#define __MATH_H__
#define _OS__OSBYTEORDER_H
#define _FD_SET
#define __GNUC_VA_LIST
#endif /* __APPLE__ */ However, I now get a more legitimate dtrace compilation error that John $ dtrace -o /Users/rkern/hg/Python-2.5.4/Include/phelper.h -DPHELPER
-I. -IInclude -I/Users/rkern/hg/Python-2.5.4/Include -C -h -s
/Users/rkern/hg/Python-2.5.4/Include/phelper.d
dtrace: failed to compile script
/Users/rkern/hg/Python-2.5.4/Include/phelper.d: line 110: relocation
remains against user symbol D``PyEval_EvalFrameEx (offset 0x5) I also tried running this without -DPHELPER as a regular DTrace script |
Look at these lines at the beginning of phelper.d: #if defined(__i386)
#define startframe PyEval_EvalFrameEx
#define endframe PyEval_EvalCodeEx
#elif defined(__amd64)
#define PyEval_EvalFrameEx PyEval_EvalFrameExReal
#define startframe PyEval_EvalFrameExReal
#define endframe PyEval_EvalCodeEx
#elif defined(__sparc)
#define PyEval_EvalFrameEx PyEval_EvalFrameExReal
#define startframe PyEval_EvalFrameEx
#define endframe PyEval_EvalFrameExReal
#endif You may need to adjust these if your compiler defines #else would be useful here. |
This is on an Intel Core 2 Duo running OS X 10.5.6. __i386 is defined. |
Robert, I have no idea how Mac OS does pstack helpers without generating
Hmm. Try adding -Z to see if that helps.
This is trying to tell you that there's no such function. Indeed, this |
2010/10/25 Jesús Cea Avión <report@bugs.python.org>:
I would say compatibility with Sun/Apple probes should not stand in |
Updated version of the patch; this ought to contain Include/pydtrace.d: $ diffstat /tmp/py3k-add-systemtap-2010-10-25.patch
Include/pydtrace.d | 10
Lib/test/test_systemtap.py | 89 ++++++
Makefile.pre.in | 10
Python/ceval.c | 75 +++++
configure | 576 +++++++++++++++++++++++ configure.in | 34 ++ Patch contains FIXMEs (sorry), which clearly need addressing. As for the objectives, do folks here agree with the "Performance" notes in http://bugs.python.org/issue4111#msg100173 ? |
Malcolm, does your last patch address the performance issue?. Ideally, dtrace support should be compiled in by default, so performance issues are important. Idealy, performance difference between compiling dtrace or not should be negligible. Until you actually use it, of course. |
We need some documentation, too. Maybe a new chapter, or a new section in the debug chapter. Better the first, since this is not only for debugging, but for performance study too. |
Compiling the code WITHOUT dtrace support gives an error: """ |
Compiling WITH dtrace... shows the same error :-???? |
I am using Solaris 10, but the configure script detects "apple" implementation. |
I believe the problem jcea is experiencing is with the
It seems solaris doesn't like the -o /dev/null part. Try |
Updated patch, removing the FIXMEs, and slightly reworking the test code. I've wrapped the whole of get_frame_marker_info with a PyErr_Fetch/PyErr_Restore pair: the PyUnicode_AsUTF8String calls could fail with a MemoryError, and we don't want to confuse the regular exception handling within ceval. I'm not sure how to write a unit test to test for this: perhaps we could corrupt the __code__ instance so that co_filename is not a PyUnicodeObject, leading to a TypeError within the function, but that's a readonly attribute. Any ideas? I've also added a unit test for a non-ASCII script (Lib/test/systemtap_sample_☠.py), containing a non-ASCII identifier (文字化け). The non-ASCII script name (Lib/test/systemtap_sample_☠.py) may be controversial: do we have anything like that in the source tree yet? Is there any risk of messing up the build across platforms, or of impacting the Hg migration? Still to-do:
|
If PyUnicode_AsUTF8String() is meant to encode a filename, you should
It would be better to generate the sample dynamically, so that users |
Still TODO:
|
I should note that I've only ever been testing this with SystemTap, on Linux. I don't have a box with DTrace, and I've never directly used it. I wouldn't today be able to diagnose a buildbot failure related to DTrace (I believe I would with systemtap, fwiw). Are there any DTrace experts around who would be willing to handle the DTrace side of this? If not, would it be reasonable to make this issue be only explicitly about "systemtap"? (e.g. perhaps change the "configure" argument accordingly?) Alternatively, given that this bug originally started as an RFE about DTrace, should we split out systemtap as a separate RFE? I'm sorry if I've "muddied the waters" by doing this. For example, the only test coverage I've written (test_systemtap.py) checks for the presence of a "stap" executable, and skips the tests if it's not found. I'm not familiar enough with DTrace to create the same for DTrace. FWIW (in response to IRC question): "thread_indent" is documented here: It looks like it may be systemtap-specific; however the only usage is within test_systemtap.py, guarded by the presence of a "stap" binary, skipping the tests if it is not found. |
For the record, replacing /dev/null with conftest.out in the configure test solves the detection problem (and allows Python to build cleanly). However, there is then a problem in test_systemtap (even when replacing "stap" with "dtrace") since the syntax for scripts doesn't seem compatible. In any case, the trivial fix for configure: diff -r 777b171a63ae -r 1784ac25b52e configure
--- a/configure Tue Oct 26 18:50:46 2010 +0200
+++ b/configure Tue Oct 26 18:54:09 2010 +0200
@@ -9178,7 +9178,7 @@
$as_echo "$with_dtrace" >&6; }
if test ! -z "$with_dtrace"
then
- if dtrace -G -o /dev/null -s $srcdir/Include/pydtrace.d 2>/dev/null
+ if dtrace -G -o conftest.out -s $srcdir/Include/pydtrace.d 2>/dev/null
then
$as_echo "#define WITH_DTRACE 1" >>confdefs.h
diff -r 777b171a63ae -r 1784ac25b52e configure.in
--- a/configure.in Tue Oct 26 18:50:46 2010 +0200
+++ b/configure.in Tue Oct 26 18:54:09 2010 +0200
@@ -2466,7 +2466,7 @@
AC_MSG_RESULT([$with_dtrace])
if test ! -z "$with_dtrace"
then
- if dtrace -G -o /dev/null -s $srcdir/Include/pydtrace.d 2>/dev/null
+ if dtrace -G -o conftest.out -s $srcdir/Include/pydtrace.d 2>/dev/null
then
AC_DEFINE(WITH_DTRACE, 1,
[Define if you want to compile in Dtrace support]) |
(my last message was about building on OpenSolaris) |
Dave, we need some kind of documentation, if we expect to ship this in Python 3.2. The deadline is only 10-15 days away. Could you write something able to be in the standard documentation?. |
configure.in has: AC_MSG_RESULT([$with_dtrace])
...
AC_MSG_RESULT($with_dtrace) Why twice? It looks confusing. |
Some more references: Read the notes under the slides: What do we need to unblock this? |
2011/4/6 Jesús Cea Avión <report@bugs.python.org>:
Summarize 30+ page discussion in a new issue.
|
jcea: I notice that on 2011-02-22 you made these changes: Did you mean to change the assignee, or was this an accident? |
Malcolm, it was a mistake. I only wanted to change the TARGET. I assign the issue to you again. Dino, I delete you from the nosy list now. Sorry for the inconvenience. My excuses to both. |
Anybody still working on this?. We missed the 2.7 boat. DO NOT MISS THE 3.3 ONE!!! :-) |
This project continues in issue bpo-13405. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: