mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
cache: release lock before clearing
Clearing the FD cache could trigger a lot of inode evicts in the kernel, which will block the cache entry destructors called by map::clear(). This prevents any cache lookups or new file opens while it happens. Move the map to an auto variable and destroy it after releasing the mutex lock. This probably has the same net result (all the bees threads will be blocked in the kernel instead of on a bees mutex), but at least the problem is outside of userspace now. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
8f0e88433e
commit
86afa69cd1
@ -122,7 +122,7 @@ namespace crucible {
|
||||
// Splice new node into list
|
||||
Value *last_bp = m_last->bp;
|
||||
THROW_CHECK0(runtime_error, last_bp);
|
||||
// New elemnt points to both ends of list
|
||||
// New element points to both ends of list
|
||||
vp->fp = m_last;
|
||||
vp->bp = last_bp;
|
||||
// Insert vp as fp from the end of the list
|
||||
@ -158,8 +158,10 @@ namespace crucible {
|
||||
void
|
||||
LRUCache<Return, Arguments...>::clear()
|
||||
{
|
||||
// Move the map onto the stack, then destroy it after we've released the lock.
|
||||
decltype(m_map) new_map;
|
||||
unique_lock<mutex> lock(m_mutex);
|
||||
m_map.clear();
|
||||
m_map.swap(new_map);
|
||||
m_last = nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user