[MemoryCache] Introduce intelligent, value-based cache pruning This CL introduces a more sophisticated, value-based pruning strategy for the in-memory resource cache, gated by the kMemoryCacheIntelligentPruning feature flag. The existing strong reference cache uses a simple LRU (Least Recently Used) eviction strategy. This can lead to suboptimal outcomes where a large, critical resource (e.g., a core stylesheet) might be evicted to make room for less important, more recently accessed resources. This new strategy calculates a "value" for each resource to make more intelligent eviction decisions. The value is a weighted score based on three factors: - Resource Type: Critical resources like CSS and fonts are given a higher intrinsic priority. - Usage Frequency: The MemoryCacheHitCount is now tracked and used, scaled logarithmically to reward frequently used assets. - Cost: The resource's EncodedSize is factored into its value. When the cache exceeds its size budget, it first removes any resources that have passed their maximum lifetime. Then, it sorts the remaining resources by this calculated value and evicts the lowest-value items until the memory target is met. Bug: 432275223 Change-Id: Ie9796cdb67de7b3b1f531dbabec10ae0170120ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6671317 Reviewed-by: Olivier Li <olivierli@chromium.org> Commit-Queue: Alex Attar <aattar@google.com> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/main@{#1490788}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.