Experience with psyco?

team23

21-05-2009 05:21:06

This is a bit OT to Python-Ogre specifically, but figured this discussion would be beneficial to essentially the same audience.

So given anyone doing 3d rendering is probably also looking to improve perf. I'm attempting to gather intelligence on how to properly use psyco to improve the speed of my project. I've got a number of speed test scripts to see how to do stuff quickly in python. I'm having a mixed bag. One of my more simple algorithmic pieces of code got a 100x speed up, and also shifted the fastest performing method fairly dramatically (The fastest by 400% became the slowest by about 10%). No classes to speak of here, just funcs testing various techniques to accomplishing tasks.

On some of my game code I'm having the opposite effect, pysco slowed down the unit tests for one of my modules by about 5x. Essentially its creating a bunch of objects/class instances, testing a few of their functions out. The issue appears to be code that runs fewer times takes longer with pysco, even if I don't count the psyco calls.

Anyone else have experience with it, or find some holy grail of psyco knoweldge?

bharling

21-05-2009 08:32:46

I use psyco a lot in my projects, but I must say I have never noticed it slowing anything down :?

In my octree class, simply doing:

import psyco
psyco.full()


gives a significant speedup, but that is the kind of algorithm psyco was designed for I think. I have never really tested out psyco to the extent you have though, so I can't claim to be any sort of expert on it.

There are alternatives though, eg: shedskin ( although its quite early in development ), or perhaps Stackless ?

Note, you won't be able to use Ogre types with shedskin, however you can use it to compile yout pure-python scripts and import them as c++ extensions.

team23

25-05-2009 06:49:37

I think I was just improperly measuring the perf w/ and w/o psyco. When implemented in my server I did see a rather nice increase in speed. The initial increase was rather modest, but it appears to be scalling much better now. My client still hasn't shown any great perf improvements with it, maybe 20 fps max. From ~115 to ~130. I think that might be due to the number of calls to the OGRE library that I have. They seem to be relatively slow (We're talking fractions of milliseconds, but from my initial purview it seemed like large fractions), so I'll have to work out some ways to either avoid them, or determine if there are faster ways to call them.

Although I'm still probably going to work on hand wrapping what I want psyco to compile, as I'm worried about running the profiler all the time. And running full() actually prevents my game from exiting properly.