I've learned. I'll share.

October 14, 2008

How to DTrace Python in OSX

DTrace is an incredible tool. It basically lets you do profiling of a live application with no performance penatly. I'm writing a Python that needed some profiling, and I found the "normal" techniques like the profile/cProfile module very lacking. Luckily, Mac OSX comes with DTrace and it even works with Python. The only snag is that it's hard to find how to use the darn thing. I finally figured it out, so I figured it pass on the knowledge.

So, here's how you use dtrace on your python application in Mac OSX:

  1. Get DTraceToolkit.
  2. Edit Python/py_cputime.d by replacing "function-entry" with "entry" and "function-return" with "exit".
  3. Call "sudo dtrace -s Python/py_cputime.d"
  4. Let it sit there a while and hit ctrl-c.
  5. Enjoy the results

I can only assume you have to edit the file because of some difference between Solaris and OSX. You can try files other than py_cputime.d, but you might have to edit them too. Not all of them work, but most do.

The last thing to know is that you have to use the python that comes with OSX. A custom-built python doesn't seem to work.

Hope that helps!


  1. Hi,

    this looks interesting but I can't make it work - I just get "dtrace: no probes specified". I tried passing a python script as an argument, but nothing happens - anything I'm missing?

  2. It appears that you no longer need to edit py_cputime.d under Snow Leopard...

  3. Hmmm
    dtrace: error on enabled probe ID 7 (ID 26198: python47:Python:PyEval_EvalFrameEx:function-return): invalid address

  4. Quickbooks is the advanced accounting software to manage business-related data. QB tool Hub is the hub of all essential tools which are used to diagnose common errors while accessing Quickbooks. You can fix minor or major issues like performance issues, PDF issues, Printing issues, and network connectivity problems.
    Quickbooks tool hub download

  5. CellAlpha is a One-Stop Platform where you can find genuine reviews. and free books, podcast, many more things

  6. Really this article is very useful and informative for everyone. And I hope you'll share more ideas and useful article with us, also visit Best Wrist Wraps

  7. Hi thank for sharing such a nice post on your blog keep it up and share more. also know most efficient propane generator

  8. Hello Friend,
    I just now only saw your post , I found its very knowledgeable and more informative. I am very impressed. Thanks for sharing this post. Keep posting more post.

    Also read: fitnessvote.com

  9. Hello Buddy,

    I am recently followed your post. It was very unique compare to others. I am very impressed to saw your post. I am got many information. Thank you for sharing your knowledge here. My knowledge was grown up to read your post.

    Also read: govt naukri

  10. Aspirants can apply online application form for current Railways job vacancies across India. To get free job notifications for RRB, RRC, Rapid Metro, and Various Other Railway Posts Freshers and Experienced candidates can subscriber to our website.govt naukri


  11. Hello Buddy,

    I am recently addicted your post. It was very unique compare to others. I am very impressed to saw your post. I am got many information. My knowledge was grown up to read your post. Thank you for sharing your knowledge here. keep doing many post.

    Also read: Download pubg lite for pc

  12. Thanks for sharing this informative content.,
    Leanpitch provides online training in Scrum Master Certification during this lockdown period everyone can use it wisely.
    Join Leanpitch 2 Days CSM Certification Workshop in different cities.
    CSM training online

    Scrum master training online


  13. Hello Dude,

    I am recently followed your post. It was very unique compare to others. I am very impressed to saw your post. I am got many information. My knowledge was grown up to read your post. Thank you for sharing your knowledge here. keep doing many post.

    Also read: See this


  14. Hello Buddy,
    I saw your post. It was really nice . I found its highly informative and knowledgeable.Thanks for sharing this post. keep going.And post more.

    Also read: eetime.com


  15. Hi mate,
    I am recently followed your post. It was very unique compare to others. I am very impressed to saw your post. I am got many information. My knowledge was grown up to read your post. Thank you for sharing your knowledge here. keep doing many post .

    also read : floor mats for vinyl floors in trucks

  16. Hi Friend,

    Just now only i joined your post. It was very informative and more knowledgeable. Your post was very interesting. Thank you for sharing this type of post. keep posting more.

    also read : best divorce lawyers in bangalore

  17. I am genuinely delighted to read this weblog posts which carries tons of useful facts, thanks for providing these kinds of data. also check here Buying Guides for UK

  18. I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts. Click Here. GAPPS for Lineage OS 17.1

  19. We at Top Review Experts help people to find the best product in UK. We provide best quality product reviews of different things. Checkout Best Product Reviews and Best Buying Guides.


  20. Uttar Pradesh Government provides jobs for 08th Pass, 10th Pass, 12th Pass, Graduates, Engineers, etc. The job seekers who meet the recruitment board's eligibility criteria can apply for the UP Govt recruitments from here.
    also read : free job alert up

  21. I am glad that I saw this post. It is an informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward to your future posts. Also, visit Gastrointestinal Drugs Manufacturers

  22. Quickbooks error code 6123 0 is a difficult error that occurs when using the application to manage day-to-day accounting processes. QuickBooks is without a doubt one of the most popular accounting software among CPAs, business owners, and solo entrepreneurs. Accounting software's features and functions can assist you in streamlining your business process and increasing profitability.

  23. hy Its very well written and very knowledgeable and attractive so that I get to learn something new quickbooks connection diagnostic tool A dialogue box for installation will display.By clicking the I agree button, you agree to the terms and conditions. Press the Next button later.Simply follow the on-screen instructions to complete the installation.

  24. Hi, I am James Aultman, I am working as a tech expert at QuickBooks support. I have 3 years of experience in this field. you have any problems related to QuickBooks Error 6155 0, then please contact our expert team of Asquare Cloud hosting at 855-856-0053.

  25. If some one wants expert view on the topic of blogging
    and site-building then i recommend him/her to go to see this web site,
    Keep up the good work.


  26. I have been browsing online greater than three hours lately, yet I by no means discovered any interesting article like yours. It is pretty price sufficient for me. In my opinion, if all website owners and bloggers made good content material as you probably did, the internet will be a lot more useful than ever before.


  27. You present a very well-written article and with some awesome information which is very helpful, like me as reader. Thanks for sharing it and also
    please visit our great site below.


  28. If you need home decor or office decor then make sure to visit zvasti

  29. Nice Post. I have been reading here for about an hour. I am a newbie and your success is very much an inspiration for me. If you want to Recover Forgot Spectrum Email Password please contact our team for instant help.

  30. Thanks for sharing this informative blog. DTrace is very important tool in Python with OSX. I used this tool some time. Keep it up and sharing more updates. Now its time to avail Kabou taxi cab services in Southfield Mi for more information.

  31. Neatly narrated the topic. Thanks for sharing this tech post. Keep sharing more tech blogs. Online Solicitation Of a Minor

  32. شركات تجديد اثاث كلاسيك تلعب دورًا مهمًا في الحفاظ على تراثنا الثقافي والتاريخي من خلال استعادة وترميم القطع الكلاسيكية. هذه الشركات تتخصص في تجديد الأثاث القديم وإعادته إلى حالته الأصلية أو تحسين مظهره ووظائفه. الأثاث الكلاسيكي يتميز بأناقته وفخامته، ولكن بمرور الزمن قد يحتاج إلى إصلاح وصيانة ليستمر في الخدمة للأجيال القادمة.

  33. The term "manycore era" refers to a technological era in the field of computing where processors or central processing units (CPUs) have numerous processing cores integrated onto a single chip. In other words, it signifies a shift from traditional single-core or dual-core processors to CPUs with a large number of cores. Each core can execute instructions and processes independently, allowing for greater parallel processing capabilities.
    Motorcycle Accident Lawyer Virginia


  34. I really appreciate this blog, It means a lot for me,, Very interesting Thanks!!

  35. This article give me a lot of inspiration. thank you for letting me see this info

  36. I appreciate this blog of yours. Post more good contents please, Thank you


Blog Archive

Google Analytics