Fetches may cause exceeding invocations of the reference-transaction hook
When implementing the reference-transaction hook, it was clear that some commands will be a nice fit, while other commands will cause many invocations of the hook and thus potentially cause a slow-down. E.g. while a
git push will cause a separate reference transaction on the remote side per reference, a
git push --atomic will only create a single reference transaction for all references and thus only execute the hook once. While we correctly cope with multiple executions of that hook via subtransactions on Gitaly's side, it may quickly become expensive.
One such case which was discovered in the context of gitaly#3353 (closed). When repositories are part of an object pool, then we regularly fetch from the original repository into the object pool in order to deduplicate objects which are shared across all repositories which are part of that pool. It turns out though that git-fetch(1) creates one transaction per reference without any mechanism to change this. Considering we have pools with hundreds of thousands of references (e.g. 800k references in context of gitlab-org/gitlab), this thus translates to 800k executions of the hook.
We may want to implement the equivalent of
git push --atomic for fetches to instead use a single reference transaction, only.