-
Notifications
You must be signed in to change notification settings - Fork 15
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
Optimize pool #36
Optimize pool #36
Conversation
When the
Sounds reasonable
thread pool can be the same as global pool: only with capacity
Instead of |
Since we now have vectors with capacity in the global pool, we start to choose between a small overhead on the mutex or an overhead on allocations/reallocations. I see #224 and foyer-rs/foyer#571, the main problem that was - when the thread does not use attributes, we spend a lot of time on synchronization. But now such threads will work as with the
Yes, but attributes must be with
API changes may indeed improve performance, but they will break large projects |
If the global pool is empty, every time we take from the local pool, we will have to try take from the global pool (with mutex synchronise) impl<T> LocalVecPool<T> {
pub fn take(&mut self) -> ReusableVec<T> {
if self.storage.is_empty() {
if self
.global_pool
.fill_empty_local(self.capacity, &mut self.storage)
{
return ReusableVec::new(self.global_pool, self.storage.pop().expect("not empty"));
}
}
ReusableVec::new(self.global_pool, Vec::new())
}
} Maybe it's good, but need tests in real cases. |
I don't have a number on the overhead of the mutex when it's in heavy conflict situation, and it may cause long tail on worst case. On the contrary, dropping the vector without reuse is rare, and reallocating large vector when collecting large amount of spans is acceptable and will not cause long tail.
It's not totally correct. The real case is that, when In short, with Did this PR resolve this problem in the other way? |
Will reopen if any progress is made on this thread. |
REUSABLE
flag is not needed.stub
method - which allows not to access to the pool if we do not use attributes (events, implLog
, etc)