Wednesday, July 22, 2009

Hello world in psyco

Aristotle said (presumably in Greek), "that which we learn, we learn by doing". In other words, there comes a point, rather quickly, when reading the manual (or even the code) is mostly waste of time :-) The only way, imo, to understand a complex program like pypy or psyco, is to run the program. So installing from sources is imperative, because we want to change the source and see what happens :-)

I've just built psyco with a "hello world" message at startup. Some notes:

- There is no point in trying to build the docs. You will simply get the psyco guide And a good thing too. The make file for the docs using something called mkhowto. Googling shows this may be part of Python tools, but there is no obvious way to get mkhowto on ubuntu.

- It looks like running "sudo python setup.py" install will do a proper build (make) of changed sources. The docs say this:

[quote]
As usual, other commands are available, e.g.

    python setup.py build_ext -i
will compile the C source and put the result directly into the py-support/ subdirectory (no administrator priviledge is required).
[end quote]

In my case, I don't mind destroying psyco by mistake, so maybe I'll just go with the plain vanilla install.

Anyway, I now have a version of psyco that I can play with. After 8 years working only with Python, I had forgotten quirks of C and Make, but the irritations, though real, are minor.

The next step will be to investigate the existing tracing and debugging capabilities of psyco.

One "significant" (if hardly earth-shaking) improvement to psyco would be to add Sherlock tracing. This would be good for development: it allows enabling and disabling of traces from the command line with minimal overhead during testing and no overhead in production.

4 comments:

  1. Sherlock sounds somewhat like dtrace & systemtap.

    Regarding the tracing stuff, I'm also fascinated by the recent push to make gdb python-debuggable (next version of gdb will have it).

    http://tromey.com/blog/?cat=17

    ReplyDelete
  2. BTW, it seems psyco could handle full leo ;-).

    I made my launchLeo.py like this:

    import psyco
    psyco.full()

    import leo.core.runLeo
    leo.core.runLeo.run()

    And it didn't crash. I'm not yet sure whether I'm fooling myself. @thin file parsing seemed faster to me.

    ReplyDelete
  3. I hope that you are using psyco2. Christian Tismer released last week, (google for the link because I cannot paste in this stupid comment editor.)

    I built it and can run my zope application about 20% faster than python 2.5 without psyco.

    ReplyDelete
  4. > Sherlock sounds somewhat like dtrace

    dtrace is Sherlock with os/compiler support. It is eerie how similar the two ideas are. dtrace is brilliant work: disabled probes add no overhead.

    Sherlock macros can be disabled at compile time, so disabled macros add no overhead either. However, enabled Sherlock macros add a small penalty, even when tracepoints are not enabled.

    BTW, did you know that Leo contains an implementation of Sherlock in leoGlobals.py? Presumably the recent switch to optparse may interfere with Sherlock's command-line logic...

    ReplyDelete