Container Registry garbage collection takes a long time to run

We are trying to run the garbage collection in our Container Registry, but due to the high accumulation of unused images in the storage, the process takes a long time to run and it does not even reach the stage of deleting the images, it just marks the images for the next stage. is there any way in which we can run garbage collection in a more segmented way?

We put the registry in read-only mode to run the process, but we would still have to keep the garbage running for a long time which can impact the push of images in the environment.

Here are some details about our GitLab:

  • we used it in the Self-Managed model (with Omnibus) in version 15.5.5
  • our registry is stored in an s3 bucket on AWS

This is the command we are running for cleanup:
sudo /opt/gitlab/embedded/bin/registry garbage-collect /var/opt/gitlab/registry/config.yml