Skip to content

Optimize ref name lookups in archive downloads

Stan Hu requested to merge sh-optimize-archive-controller-ref-names into master

When a user requests an archive download, RepositoriesController attempts to extract the given ref by finding the longest match of available branch and tag names. This is unnecessary work because unlike other controllers, the ref name isn't ambiguous. The id parameter takes the from :ref/:filename.ext, where :ref can contain any number of slashes, and :filename is simply a base filename with no slashes.

We can optimize this by doing a greedy match for the reference and using the last part as the filename. This avoid having to call out to Redis and load large sets of data.

Relates to https://gitlab.com/gitlab-com/gl-infra/scalability/issues/124

Redis calls

Before

image

After

image

Edited by Stan Hu

Merge request reports