Ticket #3704 enhancement closed fixed

Opened 5 years ago

Last modified 5 years ago

Create performance benchmark for Deferreds

Reported by: thijs Owned by:
Priority: normal Milestone:
Component: core Keywords: benchmark
Cc: thijs Branch: branches/defer-benchmarks-3704
(diff, github, buildbot, log)
Author: exarkun, peaker, thijs Launchpad Bug:


James Knight has previously implemented Deferred in Pyrex. The reason this isn't included in Twisted is that we just have no reliable, accurate way to measure what the performance changes of this are. The same applies to cdefer.c in Deferred implementation in C.

It would useful to have a benchmark which makes it possible to determine the utility of a Pyrex or C implementation of Deferred. Without actually measuring, statements about how fast Pyrex, C or pure Python is are worthless.

Deriving something from the code which showed a 5% - 20% speedup might be a good way to start on such a benchmark. It's important to cover all uses of Deferreds here. It's also okay if some parts show a slowdown, as long as the overall improvement is enough. Of course, it's better if everything is faster. :)

(ticket description derived from exarkun's comment in #2245)


defer.py Download (3.9 KB) - added by thijs 5 years ago.
defer benchmark from source:branches/cdefer-2245-4/doc/core/benchmarks (#2245)
timer.py Download (440 bytes) - added by thijs 5 years ago.
timer benchmark utility from source:branches/cdefer-2245-4/doc/core/benchmarks (#2245)

Change History

Changed 5 years ago by thijs

Changed 5 years ago by thijs


Changed 5 years ago by thijs

  • owner glyph deleted
  • keywords benchmark, review added; benchmark removed

I attached defer.py Download and timer.py Download from the latest branch for ticket #2245, that run a twisted.internet.defer benchmark, with outputting:

$ python defer.py Disabled GC
instantiate () 0.205390930176
instantiateShootCallback () 0.780241012573
instantiateShootErrback () 0.100492954254
instantiateAddCallbacksNoResult (10,) 0.00270199775696
instantiateAddCallbacksNoResult (1000,) 0.263583898544
instantiateAddCallbacksNoResult (10000,) 3.02256608009
instantiateAddCallbacksBeforeResult (10,) 0.00721502304077
instantiateAddCallbacksBeforeResult (1000,) 0.712515115738
instantiateAddCallbacksBeforeResult (10000,) 13.2036309242
instantiateAddCallbacksAfterResult (10,) 0.00922584533691
instantiateAddCallbacksAfterResult (1000,) 0.903044939041
instantiateAddCallbacksAfterResult (10000,) 8.97325801849
pauseUnpause (10,) 0.00899577140808
pauseUnpause (1000,) 0.912666082382
pauseUnpause (10000,) 15.3666989803

I suggest adding defer.py (and updating timer.py in the trunk).


Changed 5 years ago by moshez

  • branch set to branches/cdefer-2245-4

Adding branch field


Changed 5 years ago by thijs

Plans for a benchmark api are described in #3715


Changed 5 years ago by exarkun

  • branch branches/cdefer-2245-4 deleted

I think that branch field setting is erroneous.


Changed 5 years ago by exarkun

  • branch set to branches/defer-benchmarks-3704
  • branch_author set to exarkun

(In [26577]) Branching to 'defer-benchmarks-3704'


Changed 5 years ago by thijs

(In [26594]) Add copyright header refs #3704


Changed 5 years ago by thijs

  • branch_author changed from exarkun to exarkun, peaker, thijs


Changed 5 years ago by exarkun

  • owner set to exarkun
  • keywords benchmark added; benchmark, review removed

I made some trivial tweaks. I think this is good enough to merge. I'm sure we'll want to continue changing things as we get more benchmarking experience.


Changed 5 years ago by exarkun

  • status changed from new to closed
  • resolution set to fixed

(In [26630]) Merge defer-benchmarks-3704

Author: Peaker, thijs, exarkun Reviewer: exarkun Fixes: #3704

Add a benchmark for Deferred performance.


Changed 3 years ago by <automation>

  • owner exarkun deleted
Note: See TracTickets for help on using tickets.