feat: introduce global cache for GetSandboxState#78
feat: introduce global cache for GetSandboxState#78DCchoudhury15 wants to merge 3 commits intoopenkruise:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #78 +/- ##
==========================================
+ Coverage 45.75% 46.33% +0.57%
==========================================
Files 75 76 +1
Lines 4386 4457 +71
==========================================
+ Hits 2007 2065 +58
- Misses 2189 2199 +10
- Partials 190 193 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d4ec891 to
6ff4359
Compare
|
@furykerry up for review |
|
Thanks @DCchoudhury15 . Could you confirm that it actually improves performance through benchmarking? |
|
hi @AiRanthem Benchmark Results: |
|
@furykerry up for review |
|
@DCchoudhury15 the original function just query the in-memory object to get the state and there is no complex computation. In theory, it should not be the critical path of the controller. Do you have any real testing result? Possibly with pprof dump that indicates the function indeed consume significant cpu resources relatively. Otherwise, it is not wise to trade little cpu improvement with the complexity |
|
Fair point @furykerry. I'll run a profile under load and grab a pprof dump to verify if this is actually a bottleneck before i commit to the complexity. Will update with the results in a few hours. |
What this PR does / why we need it:
This PR implements a thread-safe global cache for
stateutils.GetSandboxStateto reduce performance overhead, as identified in #36.Which issue(s) this PR fixes:
Fixes #36
Special notes for your reviewer:
sync.RWMutexprotected map inpkg/utils/sandboxutils.SandboxController(clears cache on resource deletion).ResourceVersionorUIDis empty, or when running unit tests (flag.Lookup("test.v")), ensuring no side effects on existing tests.