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).