Commit 4ed8de29 authored by Gordon Guan's avatar Gordon Guan Committed by Commit Bot

cc: Remove memory pressure handler from SoftwareImageDecodeCache

The memory pressure handler of SoftwareImageDecodeCache currently
purges all unlocked cache entries upon a critical memory pressure
notification. These cache entries are primarily composed of
discardable memory.

However, the DiscardableSharedMemoryManager purges all unlocked
discardable memory upon a critical memory pressure notification as well.
It is expected that all unlocked cache entries have their respective
discardable memory unlocked.

Remove the unnecessary memory pressure handler in order to:
- Reduce the number of memory pressure notification consumers
- Reduce work performed during memory pressure handling (cache walk)

Change-Id: I196b6da65ca961cdbc525869e419f37999d4f453
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1951134Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Auto-Submit: Gordon Guan <gordonguan@google.com>
Commit-Queue: Gordon Guan <gordonguan@google.com>
Cr-Commit-Position: refs/heads/master@{#722974}
parent c7f48b54
...@@ -169,9 +169,6 @@ SoftwareImageDecodeCache::SoftwareImageDecodeCache( ...@@ -169,9 +169,6 @@ SoftwareImageDecodeCache::SoftwareImageDecodeCache(
this, "cc::SoftwareImageDecodeCache", this, "cc::SoftwareImageDecodeCache",
base::ThreadTaskRunnerHandle::Get()); base::ThreadTaskRunnerHandle::Get());
} }
memory_pressure_listener_.reset(new base::MemoryPressureListener(
base::BindRepeating(&SoftwareImageDecodeCache::OnMemoryPressure,
base::Unretained(this))));
} }
SoftwareImageDecodeCache::~SoftwareImageDecodeCache() { SoftwareImageDecodeCache::~SoftwareImageDecodeCache() {
...@@ -684,19 +681,6 @@ bool SoftwareImageDecodeCache::OnMemoryDump( ...@@ -684,19 +681,6 @@ bool SoftwareImageDecodeCache::OnMemoryDump(
return true; return true;
} }
void SoftwareImageDecodeCache::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel level) {
base::AutoLock lock(lock_);
switch (level) {
case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE:
break;
case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
ReduceCacheUsageUntilWithinLimit(0);
break;
}
}
SoftwareImageDecodeCache::CacheEntry* SoftwareImageDecodeCache::AddCacheEntry( SoftwareImageDecodeCache::CacheEntry* SoftwareImageDecodeCache::AddCacheEntry(
const CacheKey& key) { const CacheKey& key) {
frame_key_to_image_keys_[key.frame_key()].push_back(key); frame_key_to_image_keys_[key.frame_key()].push_back(key);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <vector> #include <vector>
#include "base/containers/mru_cache.h" #include "base/containers/mru_cache.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/numerics/safe_math.h" #include "base/numerics/safe_math.h"
#include "base/thread_annotations.h" #include "base/thread_annotations.h"
...@@ -112,9 +111,6 @@ class CC_EXPORT SoftwareImageDecodeCache ...@@ -112,9 +111,6 @@ class CC_EXPORT SoftwareImageDecodeCache
void ReduceCacheUsageUntilWithinLimit(size_t limit) void ReduceCacheUsageUntilWithinLimit(size_t limit)
EXCLUSIVE_LOCKS_REQUIRED(lock_); EXCLUSIVE_LOCKS_REQUIRED(lock_);
void OnMemoryPressure(base::MemoryPressureListener::MemoryPressureLevel level)
LOCKS_EXCLUDED(lock_);
// Helper method to get the different tasks. Note that this should be used as // Helper method to get the different tasks. Note that this should be used as
// if it was public (ie, all of the locks need to be properly acquired). // if it was public (ie, all of the locks need to be properly acquired).
TaskResult GetTaskForImageAndRefInternal(const DrawImage& image, TaskResult GetTaskForImageAndRefInternal(const DrawImage& image,
...@@ -142,9 +138,6 @@ class CC_EXPORT SoftwareImageDecodeCache ...@@ -142,9 +138,6 @@ class CC_EXPORT SoftwareImageDecodeCache
// Decoded images and ref counts (predecode path). // Decoded images and ref counts (predecode path).
ImageMRUCache decoded_images_ GUARDED_BY(lock_); ImageMRUCache decoded_images_ GUARDED_BY(lock_);
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_
GUARDED_BY(lock_);
// A map of PaintImage::FrameKey to the ImageKeys for cached decodes of this // A map of PaintImage::FrameKey to the ImageKeys for cached decodes of this
// PaintImage. // PaintImage.
std::unordered_map<PaintImage::FrameKey, std::unordered_map<PaintImage::FrameKey,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment