
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-12-16 23:50 byyselivanov, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| t.py | yselivanov,2017-12-18 01:22 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4907 | merged | yselivanov,2017-12-16 23:52 | |
| Messages (3) | |||
|---|---|---|---|
| msg308481 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2017-12-16 23:50 | |
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. | |||
| msg308502 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2017-12-18 01:19 | |
New changeset1b7c11ff0ee3efafbf5b38c3c6f37de5d63efb81 by Yury Selivanov in branch 'master':bpo-32348: Optimize asyncio.Future schedule/add/remove callback. (#4907)https://github.com/python/cpython/commit/1b7c11ff0ee3efafbf5b38c3c6f37de5d63efb81 | |||
| msg308503 -(view) | Author: Yury Selivanov (yselivanov)*![]() | Date: 2017-12-18 01:22 | |
The attached benchmark fromhttps://bugs.python.org/issue32204 shows that the updated Task is 15% faster. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:55 | admin | set | github: 76529 |
| 2017-12-18 01:22:51 | yselivanov | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-12-18 01:22:36 | yselivanov | set | files: +t.py messages: +msg308503 |
| 2017-12-18 01:19:50 | yselivanov | set | messages: +msg308502 |
| 2017-12-16 23:52:37 | yselivanov | set | keywords: +patch stage: patch review pull_requests: +pull_request4801 |
| 2017-12-16 23:50:13 | yselivanov | create | |