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.

python unladen swallow performance [qps]
Test/resultOriginal python 2.6.2Unladen trunk (built on 2.6.1 python)Unladen vs stock
IPv4 PTR171617562,3%
IPv4 A186419383,9%
IPv6 PTR150715724,3%
IPv6 AAAA279428953,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:

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:

-j whenhot vs. -j always [qps]
Test/resultDefault (-j whenhot)-j alwayswhenhot vs. always
IPv4 PTR17561598-9%
IPv4 A19381769-8,8%
IPv6 PTR15721416-10%
IPv6 AAAA28952648-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:


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.

Nincsenek hozzászólások.
süti beállítások módosítása