[Python-Dev] impact of cycle gc...

Skip Montanaro skip@mojam.com (Skip Montanaro)
Thu, 8 Jun 2000 09:08:13 -0500


I spent a little time poking around with a very simple test script
(appended) that makes use of Neil's cycle gc patch.  It measures the time it
takes to instantiate and delete a cycle-producing instance 100,000 times
(based upon a report in python-bugs).  For vanilla 1.6a2 ("./configure" ;
make") I got the following (last of six runs):

    memory usage @ start: 5560
    clock: 1.33 elapsed: 1.34805500507
    memory usage @ end: 18816

For 1.6a2 configured --with-cycle-gc ("./configure --with-cycle-gc ; make")
I got the following (also the last of six runs):

    memory usage @ start: 5576
    clock: 2.34 elapsed: 2.33785700798
    memory usage @ end: 5576

I was very impressed with the memory usage, but dismayed at the increased
execution time (about 75% more).  Of course, this is a test script that is
bound to show the potential performance penalty in the worst possible light.
Maybe pystone will be more indicative of the performance hit we can expect
from it.  (There's a new one - pystone.py being a better indicator of true
system performance than some other test script!)

Plain:

    Pystone(1.1) time for 10000 passes = 1.76
    This machine benchmarks at 5681.82 pystones/second

--with-cycle-gc:

    Pystone(1.1) time for 10000 passes = 1.83
    This machine benchmarks at 5464.48 pystones/second

That suggests something more like a 4% performance penalty.  I suspect that
may be the lower limit.  While I haven't looked at pystone recently, I doubt
it creates any cyclic garbage.

My next step will be to try it out on my development database server and see 
what happens.

just-another-data-point-ly y'rs,

-- 
Skip Montanaro, skip@mojam.com, http://www.mojam.com/, http://www.musi-cal.com/
"We have become ... the stewards of life's continuity on earth.  We did not
ask for this role...  We may not be suited to it, but here we are."
- Stephen Jay Gould



class fred:
    def __init__(self):
        self.indirectFunc = self.theFunc

    def theFunc(self):
        return "blah"

def test():
    f = fred()
    del f


if __name__ == "__main__":
    import os, time, sys
    sys.stdout.write("memory usage @ start: ")
    sys.stdout.flush()
    os.system("ps auxww | egrep method | egrep -v egrep | awk '{print $5}'")
    t = time.clock(), time.time()
    for x in xrange(100000):
        test()
    print "clock:", time.clock()-t[0], "elapsed:", time.time()-t[1]
    sys.stdout.write("memory usage @ end: ")
    sys.stdout.flush()
    os.system("ps auxww | egrep method | egrep -v egrep | awk '{print $5}'")