Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 908bd6d

Browse files
authored
Merge pull request #41 from everpeace/use-rlock-in-check
checking key with RLock can achieve more throughput in reserve cache
2 parents 44b501a + d51f97d commit 908bd6d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/controllers/reserved_resource_amounts.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ func newReservedResourceAmounts(n int) *reservedResourceAmounts {
4848
}
4949

5050
func (c *reservedResourceAmounts) getPodResourceAmountMap(nn types.NamespacedName) podResourceAmountMap {
51+
c.RLock()
52+
if m, ok := c.cache[nn]; ok {
53+
c.RUnlock()
54+
return m
55+
}
56+
c.RUnlock()
57+
5158
c.Lock()
5259
defer c.Unlock()
5360
if _, ok := c.cache[nn]; !ok {

0 commit comments

Comments
 (0)