Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of transport in-use list. #472

Merged
merged 2 commits into from
Aug 26, 2015

Conversation

mpaolini
Copy link
Contributor

Connector keeps its in-use transport in a dictionary _acquired
mapping hostnames/ports/ssl to lists of transports.

Applications that open many connections to the same remote web service
end up having a single-item dictionary with a long list as value.

Whenever a transport is released, the item is .remove()d from the list
that has a O(n) complexity. Also .append() on a python list can have
O(n) complexity.

In this patch we use a set instead, so .remove() and add() have O(1)

Marco Paolini added 2 commits August 22, 2015 19:58
Connector keeps its in-use transport in a dictionary `_acquired`
mapping hostnames/ports/ssl to lists of transports.

Applications that open many connections to the same remote web service
end up having a single-item dictionary with a long list as value.

Whenever a transport is released, the item is `.remove()`d from the list
that has a O(n) complexity. Also `.append()` on a python list can have
O(n) complexity.

In this patch we use a set instead, so `.remove()` and `add()` have O(1)
fafhrd91 added a commit that referenced this pull request Aug 26, 2015
Improve performance of transport in-use list.
@fafhrd91 fafhrd91 merged commit c577876 into aio-libs:master Aug 26, 2015
@fafhrd91
Copy link
Member

Thanks!

@asvetlov asvetlov added this to the 0.17.3 milestone Aug 28, 2015
@lock
Copy link

lock bot commented Oct 30, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants