[MERGE] simple performance improvement

John Arbash Meinel john at arbash-meinel.com
Thu Feb 1 15:45:40 GMT 2007

Hash: SHA1

Andrew Bennetts wrote:


> But then do_open has to do the exact same global lookup of 'open' that was being
> done anyway, *plus* the overhead of calling a python function (which is
> expensive because of the cost of setting up the frame object).  So this result
> makes no sense to me.

Thats why it made no sense to me either.

> John, how certain are you that this effect is real, and not just an artefact of
> using lsprof?

No, this was without --lsprof. It was done by doing something like:

for i in `seq 15`; do time bzr XXX; done

And then watching the 'user' time.

> If you want to avoid the expense of a global lookup, put "open=open" as a
> default arg of the function, or use Raymond Hettinger's make_constants decorator
> (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277940).  It might be
> interesting to compare the timing of this versus the other options.
> -Andrew.

I think open() is hurting us because it is charging us disk seek/kernel
overhead. I doubt it hurts because it is global versus local. Mostly I
just wanted to *measure* the open() cost, since lsprof seems to not
consider it a measurable function.

Which is also strange, since it measures stuff like file.close() time.
Or even str.split() time. So it isn't like it can't measure C function
call times, at least approximately.

Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the bazaar mailing list