Friday, 19 June 2009

Waf on Jython 2.5

Jython 2.5 has been released a few days ago, and since Waf somehow supports it, I wanted to have a closer look. Jython is an implementation of the Python programming language for the Java virtual machine.

The supposed benefits of Jython are:
  • A different threading model able to use multicore processors
  • The use of the heavily optimized Java virtual machine
  • Using waf for web applications (Maven) where people usually do not have cPython
Unfortunately, Jython seems to also use the java primitives for parsing the scripts, and executing the waf script will not work. The main Waf script contains a compressed data island in a comment section to ease redistribution. When cPython rightfully skips the comments (except \r characters), Jython has to validate all unicode characters.

For now the solution to execute waf on Jython is to use the waf directory and the waf-light script:
~/jython/bin/jython waf-light

A quick benchmark can be created by using the script located in the waf distribution:
utils/ /tmp/build 50 100 15 5

When executed, the benchmark will compile 5000 c++ files and link them by calling operating systems processes. The test was executed on a laptop having more than enough RAM and a dual core processor.

The cPython command was:
waf distclean configure build clean build clean build -p -j5
The average time of execution was 2m15 (std dev: 5 secs)

The Jython command was:
~/jython/bin/jython waf-light distclean configure build clean build clean build -p -j5
The average time of execution was 5m15 (std dev: 10 secs)

From a developer perspective, the java virtual machine and the jython start-up (7 seconds) slows down the edit-compile-run cyle, which is quite un pleasant (on cpython, waf starts instantly).

I will have a look at the profiles to understand the source of such a difference between cPython and Jython. For now Jython is not an interesting option for Waf users, and it probably will not make other applications such as Scons faster any time soon either.

No comments:

Post a Comment