Have GIL: Want Benchmarks.

by jesse in ,

IMG_0869.JPG ((Yes, this is a gratutitous picture of my daughter)) So, with the recent furvor over the GIL, one of the things GvR asked for was for someone to provide some benchmark numbers of Single v. Multi v. Other in various tests. I started working on this a night or so ago, and a lot of things have fallen out of it - not the least of which is my burning desire to really look at the GIL, threading in python and the ecosystem of alternatives.

A thing of Note: I've spawned an initial google code project to explore the alternatives/benchmarks. Read about it here.

The first test script I wrote was a simple one: take a function which calculated a number of fibonacci numbers and run it in a loop with larger and larger sets. I then:

  • Ran it twice, synchronusly.
  • Ran it twice, once in each thread (2 threads).
  • Ran it twice, but used the processing module to spawn to processes, running it once in each.
  • Ran it twice, but used the parallel python module to spawn a pool of workers for 2 processors, running it once in each.

Yes. I know that fib calculations are a processor-only activity, and that's all I wanted to do at first. I want to add tests for file access, network access, and I want to run the tests (as allowed by the extenstion modules) in PyPy, Jython and IronPython ((Yes, Daniel Watkins has started this process as well)).

In the long run - I want to make something of a test suite to not only demo the various methods/alternatives but to also to work towards a future where something like parallel python or the processing module can make it into the standard python library.

Not to mention, for those looking for alternatives to basic threading in python (or more information on threading in python). Yes, things that have to be taken into account:

  • Shared vs. unshared memory and state.
  • Ease of use/API
  • Amount of Fun.
  • Can the solution spread across machines?
  • Is it, or can it be, useful for web applications? (i.e: can it be used to spread load across processors)

If you have a test or a suggestion - drop me an email or post a comment. Heck, this might just turn out to be a learning experience for me or it could turn out to be something bigger.

Update: Wow, you guys are awesome. The private and public comments I've gotten on this have left me with a lot to think about - and hell - a lot to learn. I'm still in the toying/planning phase, so please keep feeding me information. When I get more time this weekend (if I get time) I will try to put up something cohesive, including a subversion repository and a maybe a wiki. Update 2: Hello Reddit.