• Stan Hu's avatar
    Eliminate Gitaly N+1 queries loading submodules · 11f8136d
    Stan Hu authored
    When a directory contains many submodules, we make a number of Gitaly
    N+1 queries:
    
    1. One TreeEntry RPC to look up each submodule
    2. One TreeEntry RPC to read the `.gitmodules` file
    
    The first item is redundant because we've already determined the tree
    commit is a submodule. We can eliminate this query by skipping it
    altogether.
    
    The second item can be optimized by caching the contents of
    `.gitmodules` once per directory. We already have a mechanism for
    caching this in `SubmoduleLinks`. Now we just need to use it.
    
    This significantly reduces Gitaly RPCs and closes two issues
    with one stone:
    
    1. https://gitlab.com/gitlab-org/gitlab/issues/35333
    2. https://gitlab.com/gitlab-org/gitlab/issues/194380
    11f8136d
sh-reduce-gitaly-calls-submodules.yml 106 Bytes