8000 feat(proxy): LRU eviction policy for pull through cache by yiyun-sj · Pull Request #4663 · distribution/distribution · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(proxy): LRU eviction policy for pull through cache #4663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yiyun-sj
Copy link

Description

This pr implements an LRU eviction policy for the pull through cache.

Motivation

As per discussion in #1140, because the TTL scheduler is not aware of the storage usage of the proxy (among other problems), it would be nice to have something like a least-recently-used heuristic for eviction.

Changes

The commits are made to be isolated for ease of review.

A list of rough changes:

  • moves the ttl variable into the TLLScheduler
  • make an interface for all eviction policies and make tll implement that instead
  • make configuration for eviction policies possible for different policies and still support the old ttl configuration
  • add a usage call to find total storage usage at any path
    • du is used here because there's no good package that does this (everything uses statfs which is not right). This is fine for now since only linux is supported anyways and this works in the environment from Dockerfile.
  • add the actual LRU eviction policy, which is done via a hash map and doubly linked list

@github-actions github-actions bot added area/storage area/storage/s3 area/storage/gcs area/storage/azure area/config Related to registry config area/proxy Related to registry as a pull-through cache dependencies Pull requests that update a dependency file area/docs labels Jun 30, 2025
@milosgajdos
Copy link
Member

Sign your commit, please

Summary:
This is a preliminary step to adding other eviction policies. TTL is a
TTLScheduler-specifc variable and should belong within that scope, not exported
to each component.

Signed-off-by: Sam Jia <yiyunj@twitter.com>
@yiyun-sj yiyun-sj force-pushed the proxy-lru-eviction branch from 31a2d85 to 4851e0f Compare July 1, 2025 16:01
@yiyun-sj
Copy link
Author
yiyun-sj commented Jul 1, 2025

Sign your commit, please

Oops, signed with personal email, updated.

Sam Jia added 4 commits July 1, 2025 12:46
Summary:
We need a general eviction interface to support multiple eviction policies.
This commit does two thing:
- Change configurations to support multiple eviction policies
- Change ttl scheduler to be a general eviction interface, and make ttl
  scheduler implement this eviction policy

Signed-off-by: Sam Jia <yiyunj@twitter.com>
Summary:
This is yet another supporting revision to the final LRU eviction controller.
We add the Usage call to storage drivers to find disk usage statistics at any
given path under the storage driver.

Signed-off-by: Sam Jia <yiyunj@twitter.com>
Summary: A preparatory revision to add file size parsing package: c2h5oh/datasize

Signed-off-by: Sam Jia <yiyunj@twitter.com>
Summary:
After consideration, we decided that the TTL scheduler is an unsafe eviction
policy as it could overuse disk space, causing cache pods to be evicted and
rescheduled, losing all cached entries.

This commit implements an LRU eviction policy, which allows cache entries to
persist until eviction is absolutely necessary, at which time the least recent
entry is removed.

Signed-off-by: Sam Jia <yiyunj@twitter.com>
@yiyun-sj yiyun-sj force-pushed the proxy-lru-eviction branch from 4851e0f to b0648f1 Compare July 1, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config Related to registry config area/docs area/proxy Related to registry as a pull-through cache area/storage/azure area/storage/gcs area/storage/s3 area/storage dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0