Skip to content

Improvements to GC: two-pass online run, parallel workers, better logging - #4795

Open
roman-vynar wants to merge 8 commits into
distribution:mainfrom
Quiq:gc-enhanced
Open

roman-vynar wants to merge 8 commits into
distribution:mainfrom
Quiq:gc-enhanced

Conversation

@roman-vynar

Copy link
Copy Markdown

Multiple improvements to GC:

  • Two-pass run:
  1. mark phase to mark manifests and enumerate blobs
  2. sweep phase to re-mark manifests and delete blobs eligible for this from previous phase
  • Can be run online, no downtime required, anything can be pushed in the middle
  • Parallel workers where appropriate - marking manifests, deleting blobs etc.
  • Better logging and stats

Tested to purge 200K+ blobs / 40K manifests / reclaim 1.5TB space from my two registries (backed by AWS S3 and Azure Blob).

@milosgajdos

Copy link
Copy Markdown
Member

Closing and reopening to re-trigger stuck CI

@milosgajdos milosgajdos reopened this Mar 21, 2026
@milosgajdos milosgajdos added this to the Registry/3.2.0 milestone Apr 7, 2026
Comment thread registry/storage/garbagecollect.go Resolved
Comment thread registry/storage/garbagecollect.go Resolved
Comment thread registry/storage/garbagecollect.go Resolved
Comment thread registry/storage/garbagecollect.go Resolved
Comment thread registry/storage/garbagecollect.go Resolved
Comment thread registry/storage/garbagecollect.go Resolved
Comment thread registry/root.go Resolved
@roman-vynar

Copy link
Copy Markdown
Author

Thanks @mesaglio for spending a time and looking into this!

1-2. On acquireLock() - I didn't give it much attention to this specific lock thing to be sincere but now rewrote it to account all the cases/expiring lock/reading back heldTimeout etc.
3. Resolving blob path now as blobPath, _ := pathFor(blobDataPathSpec{digest: dgst}) (as in the other existing code)
4. Set safer permissions 0600/0700 for a checkpoint stuff.
5. Avoid error thrown into defer on release lock.
6. Renamed sweep arg to sweep-only to match the mark counterpart.

Thank you again!

@milosgajdos

Copy link
Copy Markdown
Member

hey @roman-vynar mind rebasing? seems like gh CI is stuck

@roman-vynar

Copy link
Copy Markdown
Author

Rebased on top of upstream and re-pushed

@roman-vynar

Copy link
Copy Markdown
Author

BTW, it works fine since February for us by monthly cleaning our AWS/S3 and Azure/Blob backed registries.

INFO[15146] Blob deletion complete: deleted=10472 size=70.8 GiB duration=1h25m19.831985383s  go.version=go1.26.2 instance.id=01a1054d-32e4-7129-ba33-edbb9069d95d
INFO[15616] Sweep phase complete: manifests_deleted=2016 blobs_deleted=10472 space_freed=70.8 GiB layer_links_deleted=6396 duration=1h33m9.701154773s  go.version=go1.26.2 instance.id=01a1054d-32e4-7129-ba33-edbb9069d95d

Hope it will be merged soon :)

@milosgajdos

Copy link
Copy Markdown
Member

this needs a rebase @roman-vynar

@roman-vynar

Copy link
Copy Markdown
Author

Done.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants