Tornado on Pypy benchmarks

5,012 views
Skip to first unread message

Ben Darnell

unread,
Nov 27, 2011, 2:33:52 PM11/27/11
to Tornado Mailing List
Summary: Pypy 1.7 is almost twice as fast as cpython 2.7 on the
tornado HTTPServer benchmark, and three times as fast on the
template-rendering benchmark. Pypy used about three times as much
memory in both cases, but usage was stable over time (i.e. it's not
"leaking" like pypy 1.6 did).

Details: Tested on an "m1.large" EC2 instance running ubuntu 10.04
and the 64-bit binary releases of pypy (and cpython 2.7 from
https://launchpad.net/~fkrull/+archive/deadsnakes). Large instances
have two cores so the ab client wasn't competing for cpu cycles with
the python process.

ubuntu@ip-10-114-147-85:~/tornado$ /usr/bin/time python2.6
demos/benchmark/benchmark.py --quiet --num_runs=5|grep "Requests per
second"
Requests per second: 2010.39 [#/sec] (mean)
Requests per second: 2010.70 [#/sec] (mean)
Requests per second: 2000.56 [#/sec] (mean)
Requests per second: 2007.37 [#/sec] (mean)
Requests per second: 1983.27 [#/sec] (mean)
34.19user 7.29system 0:37.75elapsed 109%CPU (0avgtext+0avgdata
59040maxresident)k
0inputs+0outputs (0major+22404minor)pagefaults 0swaps

ubuntu@ip-10-114-147-85:~/tornado$ /usr/bin/time python2.7
demos/benchmark/benchmark.py --quiet --num_runs=5|grep "Requests per
second"
Requests per second: 2127.01 [#/sec] (mean)
Requests per second: 2122.64 [#/sec] (mean)
Requests per second: 2219.56 [#/sec] (mean)
Requests per second: 2209.65 [#/sec] (mean)
Requests per second: 2204.07 [#/sec] (mean)
30.62user 6.76system 0:34.83elapsed 107%CPU (0avgtext+0avgdata
60480maxresident)k
0inputs+8outputs (1major+20898minor)pagefaults 0swaps

ubuntu@ip-10-114-147-85:~/tornado$ /usr/bin/time ~/pypy-1.6/bin/pypy
demos/benchmark/benchmark.py --quiet --num_runs=5|grep "Requests per
second"
Requests per second: 2436.49 [#/sec] (mean)
Requests per second: 3289.71 [#/sec] (mean)
Requests per second: 3469.36 [#/sec] (mean)
Requests per second: 3453.05 [#/sec] (mean)
Requests per second: 3373.15 [#/sec] (mean)
22.06user 6.76system 0:25.76elapsed 111%CPU (0avgtext+0avgdata
328208maxresident)k
0inputs+3328outputs (0major+89216minor)pagefaults 0swaps

ubuntu@ip-10-114-147-85:~/tornado$ /usr/bin/time ~/pypy-1.7/bin/pypy
demos/benchmark/benchmark.py --quiet --num_runs=5|grep "Requests per
second"
Requests per second: 2673.48 [#/sec] (mean)
Requests per second: 4410.94 [#/sec] (mean)
Requests per second: 4155.42 [#/sec] (mean)
Requests per second: 4164.85 [#/sec] (mean)
Requests per second: 4626.81 [#/sec] (mean)
17.15user 6.95system 0:21.08elapsed 114%CPU (0avgtext+0avgdata
186576maxresident)k
0inputs+2680outputs (0major+59250minor)pagefaults 0swaps

ubuntu@ip-10-114-147-85:~/tornado$ /usr/bin/time python2.7
demos/benchmark/template_benchmark.py --num=1000
38.003 ms per iteration
37.56user 0.54system 0:38.14elapsed 99%CPU (0avgtext+0avgdata 46672maxresident)k
0inputs+136outputs (0major+119479minor)pagefaults 0swaps

ubuntu@ip-10-114-147-85:~/tornado$ /usr/bin/time ~/pypy-1.7/bin/pypy
demos/benchmark/template_benchmark.py --num=1000
12.899 ms per iteration
13.08user 0.03system 0:13.11elapsed 99%CPU (0avgtext+0avgdata
153296maxresident)k
0inputs+144outputs (0major+14267minor)pagefaults 0swaps

-Ben

Ovidiu Predescu

unread,
Nov 27, 2011, 10:48:58 PM11/27/11
to python-...@googlegroups.com
Whoa, nice!

I'd love to port my code to PyPy, but psycopg2 is not compatible with
it. I remember someone mentioned another Postgres driver designed for
pypy, but I cannot seem to find the email in the archive. Any
pointers?

Thanks,
Ovidiu

Leslie Huyan

unread,
Nov 28, 2011, 12:31:57 AM11/28/11
to python-...@googlegroups.com
Hi Ben, nice benchmark.
Can I take a look at the benchmark code please?

Leslie

Ben Darnell

unread,
Nov 28, 2011, 12:46:30 AM11/28/11
to python-...@googlegroups.com

Frank Smit

unread,
Nov 28, 2011, 3:55:34 AM11/28/11
to python-...@googlegroups.com
Here's the one: https://github.com/mvantellingen/psycopg2-ctypes

I tried it for a bit and async connections work.

Ovidiu Predescu

unread,
Nov 28, 2011, 2:42:44 PM11/28/11
to python-...@googlegroups.com
Great Frank, thank you!

Didip Kerabat

unread,
Nov 30, 2011, 11:05:59 AM11/30/11
to python-...@googlegroups.com
As for MySQLdb users, looks like quora did open sourced their mysql ctypes. https://github.com/quora/mysql-ctypes

The naming convention looks like it is a drop-in replacement of MySQLdb.

- Didip -

Jagtesh Chadha

unread,
Dec 1, 2011, 12:56:37 AM12/1/11
to python-...@googlegroups.com
That's a great benchmark Ben.

Just a thought on the Quora MySQLdb replacement. Does it have any performance implications over the C based MySQLdb library?
Reply all
Reply to author
Forward
0 new messages