https://gitlab.com/gitlab-org/gitaly/blob/master/internal/se...
I'm not an expert in this abomination, but it looks all the world like invoking "git show-ref --verify".
(Of course a Git ref is usually just a file in .git with a SHA1 in it. They don't care about the SHA1, so really they are launching a Git process for a file exists operation. This used to take them 400ms, but now it's only 100ms!)
(disclaimer: I work at GitLab, not on this project though)
But ultimately this is the main Git interface for the remainder of the site, and it is apparently already sharded so only has to deal with a limited number of repositories. You can use libgit2 on a low-enough level that you can just keep and mutate repository state in memory. Something like a ref exists should be just a hash table lookup, and there are a bunch of other commands where gains can be had when you are not starting from scratch on every API call.
(This is what github is doing. They started out with grit, which was some parts of Git reimplemented in Ruby and then launching git for heavy-weight stuff. Nowadays they use rugged, the ruby bindings for libgit2.)
Read-only requests with no security implications get done by in the worker process, which has read permissions for public files. More complex requests spawn a Git client program.
It would be so uncool, though.