Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Proposal for easier cache tuning. #9903

Closed
@erikjohnston

Description

@erikjohnston

We want caches to be more easily tunable (without requiring expert knowledge), and ideally for the defaults to provide a decent experience out of the box. The flip side is that we want to ensure that we don't use unnecessary amounts of memory, as a) we want to keep memory usage low in general, and b) more memory increases the GC resource usage.

What I'm currently thinking is being able to set thresholds based on the total memory usage of caches and/or last access time. That way we can have levels such as:

  1. Evict anything older than 30mins
  2. Evict anything older than 15 mins while memory usage is above 512MB
  3. Evict anything older than 5 mins while memory usage is above 1GB

The idea being that we want to stay under the memory limits without evicting recently used stuff from the caches. It'll probably take some experimentation to come up with the right values.

This could efficiently be implemented by having the LruCache also insert nodes into a global linked list, with last access times tracked per node. To use memory limits we'd also need to either a) enable the memory tracking in #9881, or b) use jemalloc to get an accurate measure of how much allocated memory is actually being used.

We may also want to take into account how often a node has been accessed. E.g. we may wish to expire nodes that have only ever been accessed once more aggressively than for those that get accessed more periodically (the LRU nature of the cache takes this into account somewhat already).

Metadata

Metadata

Assignees

Labels

T-TaskRefactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions