I note that in r60567 Christian checked in support for compacting the
int and float freelists.

I have no problems with the implementation, but would like to note
that I have been experimenting with an alternate approach which doesn't
require the addition of a knob to initiate the compacting.

Probably in response to the same stimulus as Christian it occurred to me
that the freelist approach had been adopted long before PyMalloc was
enabled as standard (in 2.3), and that much of the performance gains
between 2.2 and 2.3 were in fact due to PyMalloc.

So I've been testing with the freelists ripped out and ints and floats
reverted to fairly standard PyObject_New allocation (retaining the small
int interning) and thus relying on PyMalloc to do any compaction.

The results have been somewhat surprising...

The short version is that:
- for ints, the freelist is ahead of PyMalloc by a very small margin
   (<4%)
- for floats, the freelist is a long way behind PyMalloc (>35% slower)

This without invoking freelist compaction by the way (though PyMalloc
is releasing empty arenas).

I don't know what's pessimising the float freelist, but the results are
similar on 2 boxes:
- AMD Athlon XP-1600+, 512MB RAM, FreeBSD 6.1, gcc 3.4.4
   (~27k pystones)
- AMD Athlon XP-2500+, 512MB RAM, OS/2 v4 with EMX, gcc 2.8.1
   (~38k pystones)

If there's interest in following this up, I can put my patches to 
intobject.c and floatobject.c into the tracker.

Test scripts:
a) int

<code>
# test routine - integer

import time

def b(time_now=time.clock):
     limit_val = 2000000
     start_time = time_now()
     for j in xrange(25):
         d = {}
         for i in xrange(limit_val):
             d[i] = i + limit_val
     return time_now() - start_time

if __name__ == '__main__':
     print 'elapsed: %s s' % b()
</code>

b) float

<code>
# test routine - float

import time

def b(time_now=time.clock):
     limit_val = 1000000
     vals = range(limit_val)
     offset = limit_val * 1.0
     start_time = time_now()
     for j in xrange(25):
         d = {}
         for i in [float(x) for x in vals]:
             d[i] = i + offset
     return time_now() - start_time

if __name__ == '__main__':
     print 'elapsed: %s s' % b()
</code>

The times I've obtained were:

case                  XP1600/Fbsd     XP2500/OS2 (*)
1) int freelist          38.1s           24.6s
2) int pymalloc          39.0s           25.3s
3) float freelist
    (with int freelist)   75s             46.1s
4) float pymalloc
    -with int freelist    55s             29.0s
    -with int pymalloc    55.5s           29.5s

(*) OS/2 tests based on patched 2.5.1 sources rather than svn trunk.
     FreeBSD tests based on svn trunk checked out at 1050UTC 7Feb08.

-- 
-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: [EMAIL PROTECTED]  (pref) | Snail: PO Box 370
        [EMAIL PROTECTED]             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to