Comment 14 for bug 740759

Revision history for this message
Andrew Bennetts (spiv) wrote : Re: [Bug 740759] Re: creating bzrdir on launchpad is slow (BzrDirFormat.initialize_ex_1.16)

John A Meinel wrote:
[...]
> So of the 664ms to actually initialize, 515ms of it is spent in
> translateVirtualPath. However, of that time, 410ms is actually spent
> handling failure.__getstate__
> 35k calls to safe_repr sure seems like a lot for 29 calls to the
> function. It hints that exception handling in twisted is really quite
> expensive. Though I'm sure --lsprof exacerbates this.

That is a lot of calls. I wonder what the failures actually are, and if
they can be avoided?

Twisted's Failure class is definitely uglier and more expensive than it
ought to be.

The __getstate__ calls are probably due to calls to
failure.cleanFailure(), and the most likely caller of that is Deferred;
when a Deferred finds it can't run any more callbacks/errbacks
immediately (there are no more callbacks in the chain, or the most
recent callback returned an unfired Deferred, etc), then it calls
cleanFailure basically to release memory. Given how expensive
cleanFailure can be that's a fairly unsatisfactory compromise. It would
be nice to figure out something better.

-Andrew.