Closed
Description
If we look at this code
Lines 56 to 62 in f92bace
we can see that .Reset simply takes a lock then allocates a fresh map by discarding the previous one.
Suggestion
We can reduce on CPU & RAM pressure by using the map clearing idiom aka
func (c *LRUTxCache) Reset() {
c.mtx.Lock()
defer c.mtx.Unlock()
for key := range c.cacheMap {
delete(c.cacheMap, key)
}
c.list.Init()
}
which in performance wisdom is a known and accepted Go idiom for reducing CPU & RAM pressure by reusing the map.
Metadata
Metadata
Assignees
Labels
No labels