[Twisted-Python] Performance issue in reactor.callLater

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Thu Sep 9 05:39:07 EDT 2004

James Y Knight schrieb:
> To me, it seems like the right thing is what I think you had before:
> 1) on cancel, mark it canceled

Sorry, I do not think that that is a good idea anymore.

The reason is:

1) If we remove the entry during the call to cancel(), it takes log(N) time and is only done once.

2) If we do /not/ remove the entry, cancel() takes constant time (set a flag), but runUntilCurrent has to deal with a larger stack on each iteration. So this may slow down things considerably if many delayed calls are cancelled and remain on the stack.

Here the right place for the trade-off is in cancel().

The patch I finally submitted as a bug report does 1).


More information about the Twisted-Python mailing list