Skip to content
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

feat: use lease to manage local cache for gc #157

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

Desiki-high
Copy link
Collaborator

@Desiki-high Desiki-high commented Jul 5, 2023

Now acceld's GarbageCollect will clear all caches when content size is over the threshold. We should use the lease to choose which content blob should be reserved. The updatedAt can help us to choose blobs.

Changes:

  • Rename the updatedAt to usedat and move to lease bucket (labels).
  • Add the usedCountLabel in lease bucket.
  • Rewrite GC by lease. When the local cache size is over eighty percent of the threshold, gc will delete local blobs until the size is less than eighty percent of the threshold which is order by usedat(LRU).

TODO:
We should update the order of GC from LRU to LRFU by usedCountLabel.

Reference: #141.

pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
@Desiki-high Desiki-high force-pushed the feat-lm branch 4 times, most recently from ef32374 to 031b2a5 Compare July 14, 2023 05:15
@Desiki-high Desiki-high force-pushed the feat-lm branch 4 times, most recently from e1d5bbc to c36c25b Compare August 7, 2023 05:41
pkg/content/content.go Outdated Show resolved Hide resolved
pkg/content/content.go Outdated Show resolved Hide resolved
Also add usedAtLabel and usedCountLabel in lease bucket,
usedAtLabel is the latest used time of each blob, usedCountLabel
helps to count the used times of each blob.

Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
@Desiki-high Desiki-high force-pushed the feat-lm branch 2 times, most recently from 5c3d3d2 to 9439819 Compare August 9, 2023 07:40
@Desiki-high Desiki-high requested a review from imeoer August 9, 2023 09:48
pkg/content/content.go Outdated Show resolved Hide resolved
We can use leaseManager to keep the content blob cache. LeaseManager will
create lease of eache content blob and update the latest used time and
used counts of each blob in lease bucket.
We call updateLease in content store ReadAt and cleanLease in GC.

Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
@imeoer imeoer merged commit f132200 into goharbor:main Aug 10, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants