psyco out of memory

I

Ivan Voras

I have this simple *dumb* benchmark-like program:

#import psyco
#psyco.full()

d = 0.0
for i in xrange(1000000000):
d += i
print d

I though I'd use it to try out psyco, but no, when I enable the first
two lines, python core-dumps:

Fatal Python error: psyco: out of memory
Abort (core dumped)

Now this isn't a real-world application example, but it's certainly
unexpected. Did psyco try to mimic range() and allocate 1G of integers?

(I'm running python 2.3.4 on FreeBSD 5)
 
M

Michael Hudson

Ivan Voras said:
I have this simple *dumb* benchmark-like program:

#import psyco
#psyco.full()

d = 0.0
for i in xrange(1000000000):
d += i
print d

I though I'd use it to try out psyco, but no, when I enable the first
two lines, python core-dumps:

Fatal Python error: psyco: out of memory
Abort (core dumped)

Hum. Are you using the ivm or the x86 backend?

Also, you might have better luck just using range()...

Cheers,
mwh
 
I

Ivan Voras

Ivan said:
(I'm running python 2.3.4 on FreeBSD 5)

Hmph. I tried on WinXP and it works. Maybe it's a platform-specific bug.

(Still, I'm surprised how slow it is. The same "program" in Java takes
about 10sec, and here it's passed 5 minutes and I'm still waiting...)
 
T

Tim Hochberg

Ivan said:
Hmph. I tried on WinXP and it works. Maybe it's a platform-specific bug.

(Still, I'm surprised how slow it is. The same "program" in Java takes
about 10sec, and here it's passed 5 minutes and I'm still waiting...)

I believe that psyco only accelerates functions and methods. So, it's
not going to do anything in the case you presented. This makes it
particularly suprising that it broke. Try wrapping up your loop in a
function. And with Psyco range is (or at least used to be) better. Like so:

import psyco

def f():
d = 0.0
for i in range(1000000000):
d += i
print d
psyco.bind(f)

f()

That ran in about a minute here. Psyco won't speed up floating point
operations near as much as integer ops at present, hence its speed
deficit with respect to java.

-tim
 
C

Christian Tismer

It crashes here, right?

I think I know this problem. Armin submitted
a patch concerning memory mapping. Upgrading to
the current cvs version and building by hand should help.

You need to wrap this into a function, or you will
not get accelerated.
Hum. Are you using the ivm or the x86 backend?

Also, you might have better luck just using range()...

No, there is no difference using range or xrange, but the
fact that your machine will blow up if Psyco is not in
place and you try to build a range that huge. That's why
I prefer xrange.

ciao - chris


p.s.:
Btw. there has been a bug in Psyco which made the xrange
case slower when using Psyco with Stackless. No Stackless bug,
simply the case that I do a PyType_Ready() on xrange which
standard Python dowsn't, and that inserts a defaul init
function that Psyco did not support (until Wednesday)

--
Christian Tismer :^) <mailto:[email protected]>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
 
I

Ivan Voras

Tim said:
That ran in about a minute here. Psyco won't speed up floating point
operations near as much as integer ops at present, hence its speed
deficit with respect to java.

Yes, it took about minute here too. While it is a ~ 30x speed gain, it
shows there's still space for improvement :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top