PyPy 1.2 released!

6 views
Skip to first unread message

Joe Barnhart

unread,
Mar 19, 2010, 7:13:10 PM3/19/10
to web2py-users
I have to say... WOW. Just WOW. The performance they're getting --
even at this "post beta" stage of development -- is breathtaking.
They've benchmarked Twisted on it and seen huge performance gains vs.
CPython 2.6.2

http://morepypy.blogspot.com/2010/03/hello.html

I can't wait to download it on the mac tonight and see if web2py runs
"out of the box". Do we have any easy way of benching performance
under PyPy? I'm a little concerned about the "exec" method of
executing code not "playing well" with the PyPy JIT.

mdipierro

unread,
Mar 19, 2010, 10:06:39 PM3/19/10
to web2py-users
Keep us posted. this is important!

Joe Barnhart

unread,
Mar 20, 2010, 4:22:02 AM3/20/10
to web2py-users
I installed PyPy on a Mac. I discovered it needs openssl to run, so I
used MacPorts to install openssl and everything ran as expected. I
was able to run web2py.py under PyPy and the management interface
works perfectly! BUT...

I'm gettng a Sqlite3 error whenever I try to run a site:

Traceback (most recent call last):
File "/Users/xxx/Work/web2py/gluon/restricted.py", line 173, in
restricted
exec ccode in environment
File "/Users/xxx/Work/web2py/applications/yyy/models/db.py", line 9,
in <module>
db=SQLDB('sqlite://swim.db') # if not, use SQLite or
other DB
File "/Users/xxx/Work/web2py/gluon/sql.py", line 889, in __init__
self._pool_connection(lambda : sqlite3.Connection(dbpath,
File "/Users/xxx/Work/web2py/gluon/sql.py", line 829, in
_pool_connection
self._connection = f()
File "/Users/xxx/Work/web2py/gluon/sql.py", line 889, in <lambda>
self._pool_connection(lambda : sqlite3.Connection(dbpath,
AttributeError: 'module' object has no attribute 'Connection'

Joe Barnhart

unread,
Mar 20, 2010, 3:58:14 PM3/20/10
to web2py-users
OK -- more info.

I discovered that sqlite3 was not being loaded by sql.py in gluon.
The library must be structured oddly because it wants something like:

from sqlite3 import dbapi2 as sqlite3

After hacking sql.py in this fashion, pypy ran perfectly! ...for
about 30 seconds!

After that time, I got a "too many open files" error for every
request. It seems that PyPy isn't very aggressive about GC'ing closed
files, so I need to research that aspect.

It may be a moot question, because from my brief tests I believe the
JIT will not speed up code loaded and run via "exec". I noticed my
worst page load takes about 6-7 seconds under OSX Python 2.5.2 but
takes about 12 seconds under PyPy.

mdipierro

unread,
Mar 20, 2010, 8:34:15 PM3/20/10
to web2py-users

On Mar 20, 2:58 pm, Joe Barnhart <joe.barnh...@gmail.com> wrote:
> OK -- more info.
>
> I discovered that sqlite3 was not being loaded by sql.py in gluon.
> The library must be structured oddly because it wants something like:
>
> from sqlite3 import dbapi2 as sqlite3

Can you send me the patch?

> After hacking sql.py in this fashion, pypy ran perfectly!   ...for
> about 30 seconds!
>
> After that time, I got a "too many open files" error for every
> request.  It seems that PyPy isn't very aggressive about GC'ing closed
> files, so I need to research that aspect.

This is bad. I think we explicitly close any file we open but we may
be wrong. If you find out the source of the problem, please let me
know.

Joe Barnhart

unread,
Mar 22, 2010, 12:59:07 AM3/22/10
to web2py-users
So you beat me to it, Massimo! I needed to do a little background
study. I downloaded and installed Mercurial for the Mac, then I
cloned the repository at google. I went to make my change to sql.py
and found you'd beat me to it!

But next time, I'll be better prepared to send you a patch. I'm up to
date and pulling the latest sources now -- I don't want to be a bad
citizen by sending patches on old code.

I think I'll nose around a little and see if I can discover where the
files are not being closed. The PyPy site specifically states that
files do NOT get closed automatically when they go out of scope (seem
like kind of a big difference to me) so that is where I will look.

Joe Barnhart

mdipierro

unread,
Mar 22, 2010, 1:47:40 AM3/22/10
to web2py-users
LOL. In the end your email contained all the info needed.

I agree with you that not closing files when they go out of scope is a
major incompatibility.

Massimo

Reply all
Reply to author
Forward
0 new messages