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

tls: performance of allocating slot could be improved, it's O(N) for now. #7975

Closed
stevenzzzz opened this issue Aug 20, 2019 · 2 comments
Closed
Assignees
Labels

Comments

@stevenzzzz
Copy link
Contributor

Issue Template

Title: Allocating a slot currently including a linear searching for empty slot in the slots vector, in the case of frequent allocating and deallocating, this could be a performance issue.

Description:

in InstanceImpl::allocateSlot, a linear search is done before expanding the slots_'s size.

https://github.com/envoyproxy/envoy/blob/master/source/common/thread_local/thread_local_impl.cc

for (uint64_t i = 0; i < slots_.size(); i++) {
if (slots_[i] == nullptr) {
std::unique_ptr slot(new SlotImpl(*this, i));
slots_[i] = slot.get();
return slot;
}
}

We can maintain a free list to return existing free slot in O(1).

@stevenzzzz
Copy link
Contributor Author

/assign stevenzzzz

@mattklein123
Copy link
Member

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants