[issue32348] Optimize asyncio.Future schedule/add/remove callback

2017-12-17 Thread Yury Selivanov

Change by Yury Selivanov :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32348] Optimize asyncio.Future schedule/add/remove callback

2017-12-17 Thread Yury Selivanov

Yury Selivanov  added the comment:

The attached benchmark from https://bugs.python.org/issue32204 shows that the 
updated Task is 15% faster.

--
Added file: https://bugs.python.org/file47335/t.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32348] Optimize asyncio.Future schedule/add/remove callback

2017-12-17 Thread Yury Selivanov

Yury Selivanov  added the comment:


New changeset 1b7c11ff0ee3efafbf5b38c3c6f37de5d63efb81 by Yury Selivanov in 
branch 'master':
bpo-32348: Optimize asyncio.Future schedule/add/remove callback. (#4907)
https://github.com/python/cpython/commit/1b7c11ff0ee3efafbf5b38c3c6f37de5d63efb81


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32348] Optimize asyncio.Future schedule/add/remove callback

2017-12-16 Thread Yury Selivanov

Change by Yury Selivanov :


--
keywords: +patch
pull_requests: +4801
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32348] Optimize asyncio.Future schedule/add/remove callback

2017-12-16 Thread Yury Selivanov

New submission from Yury Selivanov :

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.

--
assignee: yselivanov
components: asyncio
messages: 308481
nosy: asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Optimize asyncio.Future schedule/add/remove callback
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com