Where are we...

So with a fairly extensive set of Cython wrappers, running a fairly large, heavy VRML world with transparencies and all the rest, I see a noticeable, but modest, speedup.

The world I'm testing on goes from ~12.8fps (avg) to 15.5fps (avg), that's a nice 20% speedup.  On average OpenGLContext now spends around 20% of rendering time in PyOpenGL calls.  Rendering is around 15% of total (most of the time is spent sleeping/waiting and/or processing scenegraph updates and events), for 3-4% of total application time spent in OpenGL and wrapper overhead.

If I were just worried about OpenGLContext performance, I'd stop working on PyOpenGL optimization.  It is nowhere near the "big issue" in performance for OpenGLContext now, but PyOpenGL is used by a lot more projects and there's savings that could be had if I were to more tightly bind the Cython wrappers so that they directly call C APIs instead of Python generic object APIs where possible.  There are also still a number of converter/arrayhelper types that could be profitably converted to Cython for modest wins.

I have *not* tried to link OpenGL into Cython.  At the moment all calls are still through ctypes Function objects, which is a noticeable overhead, but should keep the build system relatively simple.  Cython is linking against numpy for one module, but hopefully that will be relatively painless.

The accelerator module is going to need a lot of testing, as is the unaccelerated version.  I've already fixed multiple bugs in the non-Cython wrapper module as a result of testing this evening.  I might put in another 2 days on the optimization and cleanup/testing, at which point I should probably think about looking for some contracts and getting back to having an income.


  1. Lucian

    Lucian on 04/30/2009 6:08 a.m. #

    All these speedups are great and Cython is very nice to work with.

    However, I'm slightly worried about PyOpenGL on other implementations, like PyPy or Jython. PyPy for example support ctypes, but not the CPython C API. Will the Cython parts be optional speedup modules?

  2. Mike C. Fletcher

    Mike C. Fletcher on 04/30/2009 10:59 a.m. #

    The version without the Cython wrapper is what I'm referring to as the "unaccelerated wrapper" above. The accelerator module is entirely optional and pure-python versions will continue to be available.

  3. Lucian

    Lucian on 04/30/2009 1:07 p.m. #

    Oops, looks like I haven't read it carefully enough. Sorry :)

    Keep up the great work!

Comments are closed.


Pingbacks are closed.