diff options
author | 2023-05-19 10:48:02 -0400 | |
---|---|---|
committer | 2023-05-19 14:51:02 +0000 | |
commit | 57cee762daf879bda7fa4b8adfd284233b4b6320 (patch) | |
tree | b61544b085fb35c02f1eb7181e391a6f12782e89 | |
parent | de9ac4dc0ad221913fa6be63dae2e35af61c78b5 (diff) |
Fix rate limiting comparison
Also tweak deferred cleanup for persistent processes to reduce
total memory usage.
Bug: 275486055
Test: watching gfxinfo of sysui
Change-Id: Id679a43062941c096d437b76aebe1a5a9ca0b404
-rw-r--r-- | libs/hwui/MemoryPolicy.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/MemoryPolicy.h | 2 | ||||
-rw-r--r-- | libs/hwui/renderthread/CacheManager.cpp | 5 |
3 files changed, 8 insertions, 2 deletions
diff --git a/libs/hwui/MemoryPolicy.cpp b/libs/hwui/MemoryPolicy.cpp index ca1312e75f4c..21f4ca79b68c 100644 --- a/libs/hwui/MemoryPolicy.cpp +++ b/libs/hwui/MemoryPolicy.cpp @@ -28,7 +28,10 @@ namespace android::uirenderer { constexpr static MemoryPolicy sDefaultMemoryPolicy; constexpr static MemoryPolicy sPersistentOrSystemPolicy{ .contextTimeout = 10_s, + .minimumResourceRetention = 1_s, + .maximumResourceRetention = 10_s, .useAlternativeUiHidden = true, + .purgeScratchOnly = false, }; constexpr static MemoryPolicy sLowRamPolicy{ .useAlternativeUiHidden = true, diff --git a/libs/hwui/MemoryPolicy.h b/libs/hwui/MemoryPolicy.h index 347daf34f52a..e10dda990dec 100644 --- a/libs/hwui/MemoryPolicy.h +++ b/libs/hwui/MemoryPolicy.h @@ -53,6 +53,8 @@ struct MemoryPolicy { // The minimum amount of time to hold onto items in the resource cache // The actual time used will be the max of this & when frames were actually rendered nsecs_t minimumResourceRetention = 10_s; + // The maximum amount of time to hold onto items in the resource cache + nsecs_t maximumResourceRetention = 100000_s; // If false, use only TRIM_UI_HIDDEN to drive background cache limits; // If true, use all signals (such as all contexts are stopped) to drive the limits bool useAlternativeUiHidden = true; diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index babce88b8e1e..8f81dbad2320 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -277,12 +277,13 @@ void CacheManager::onThreadIdle() { const nsecs_t now = systemTime(CLOCK_MONOTONIC); // Rate limiting - if ((now - mLastDeferredCleanup) < 25_ms) { + if ((now - mLastDeferredCleanup) > 25_ms) { mLastDeferredCleanup = now; const nsecs_t frameCompleteNanos = mFrameCompletions[0]; const nsecs_t frameDiffNanos = now - frameCompleteNanos; const nsecs_t cleanupMillis = - ns2ms(std::max(frameDiffNanos, mMemoryPolicy.minimumResourceRetention)); + ns2ms(std::clamp(frameDiffNanos, mMemoryPolicy.minimumResourceRetention, + mMemoryPolicy.maximumResourceRetention)); mGrContext->performDeferredCleanup(std::chrono::milliseconds(cleanupMillis), mMemoryPolicy.purgeScratchOnly); } |