Python unladen swallow performance
2009.07.16. 11:11
Recently, there were some amount of buzz about Google's (?) project, named unladen swallow, which targets a considerable amount of speedup of (C)python interpreter.
I use a DNS server -written in python-, because it's flexible and easy to program, so I thought I should give unladen a peek.
Test/result | Original python 2.6.2 | Unladen trunk (built on 2.6.1 python) | Unladen vs stock |
IPv4 PTR | 1716 | 1756 | 2,3% |
IPv4 A | 1864 | 1938 | 3,9% |
IPv6 PTR | 1507 | 1572 | 4,3% |
IPv6 AAAA | 2794 | 2895 | 3,6% |
One of the main parts of unladen swallow is the JIT, leaving out the bytecode interpreter. The above results are made with the default setting, which makes JIT to kick in only for "hot" code, which is executed a lot of times.
But there is a "-j always" option, which compiles every python code into native, so -in theory- they could run faster. In theory.
Running my program with "-j always", the machine began to work hard and instead of the normal few seconds startup time, I had to wait more than a minute.
After the compilation ended, I got this in top:
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
24653 root 3 116 0 767M 712M ucond 1 0:00 0.00% python
So python ate 712 MiB memory (otherwise it doesn't chew up more than 10-20 M), obviously because of the fact, that it had to compile every imported modules and load them into memory, or maybe it forgot to release the allocated memory at compile time...
Let's see how this performs against the default setting:
Test/result | Default (-j whenhot) | -j always | whenhot vs. always |
IPv4 PTR | 1756 | 1598 | -9% |
IPv4 A | 1938 | 1769 | -8,8% |
IPv6 PTR | 1572 | 1416 | -10% |
IPv6 AAAA | 2895 | 2648 | -8,6% |
As it stands, it's better to leave -j at its default setting, and only compile the often used code -during run-.
As you can see, the performance increase in negligible, but I hope that it will change in the future. It would be good to have a python runtime environment, which preserves the language's flexibility and freedom, but offers more speed than Cpython.
A bejegyzés trackback címe:
Kommentek:
A hozzászólások a vonatkozó jogszabályok értelmében felhasználói tartalomnak minősülnek, értük a szolgáltatás technikai üzemeltetője semmilyen felelősséget nem vállal, azokat nem ellenőrzi. Kifogás esetén forduljon a blog szerkesztőjéhez. Részletek a Felhasználási feltételekben és az adatvédelmi tájékoztatóban.