Skip to content

Improve performance of transport in-use list.#472

Merged
fafhrd91 merged 2 commits intoaio-libs:masterfrom
elastic-coders:optimize_acquired_list
Aug 26, 2015
Merged

Improve performance of transport in-use list.#472
fafhrd91 merged 2 commits intoaio-libs:masterfrom
elastic-coders:optimize_acquired_list

Conversation

@mpaolini
Copy link
Copy Markdown
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
Copy Markdown
Member

Thanks!

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

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