Author yselivanov
Recipients asvetlov, yselivanov
Date 2017-12-16.23:50:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513468213.29.0.213398074469.issue32348@psf.upfronthosting.co.za>
In-reply-to
Content
Key observation: 99.9% of the time Futures and Tasks have only one callback.  

Currently we have a list of callbacks in each Future/Task.  We can avoid list object allocation if we add a field to store the first callback.  This way we'll only need to ever allocate the list if a Future/Task has more than one done callbacks.

asyncio with the proposed patch applied shows that 3-6% better performance of an asyncio echo server implemented using asyncio.streams.  This benchmark involves quite a bit of other Python code, so this improvement is actually quite significant.

The patch consists of:

1. first callback / callbacks list refactoring.

2. a free list implementation for Future.__await__ objects (which are created on almost all awaits in asyncio).

3. a big cleanup of the code, ensuring that Future/Task are always initialized properly.
History
Date User Action Args
2017-12-16 23:50:13yselivanovsetrecipients: + yselivanov, asvetlov
2017-12-16 23:50:13yselivanovsetmessageid: <1513468213.29.0.213398074469.issue32348@psf.upfronthosting.co.za>
2017-12-16 23:50:13yselivanovlinkissue32348 messages
2017-12-16 23:50:13yselivanovcreate