1. 06 Aug, 2020 2 commits
    • Sean McGivern's avatar
      Optimise happy-path lookup for refs without slashes · 04a5b342
      Sean McGivern authored
      Fetching all references for a repository uses SMEMBERS, which can be
      quite slow. We need to fetch all references to resolve ambiguities in
      certain edge cases. However, most references do not contain a slash, and
      most repositories do not contain ambiguous references (where a tag is a
      prefix of a branch or vice versa).
      
      In those cases, we can trade two slow-ish Redis calls (SMEMBERS to get
      all tags and branches) for a maximum of four much faster Redis calls,
      because they are all GETs:
      
      1. One for the feature flag (which will go away in future hopefully).
      2. One to check if the repository has ambiguous refs.
      3. One for checking membership of branch names.
      4. One for checking membership of tag names (only if we didn't match a
         branch).
      
      In the worst case - when the repository does not contain ambiguous refs
      - we add those calls to the existing calls, but this should still not be
      a huge amount of overhead in that case.
      
      When the feature flag is disabled (which is the default), we're just
      adding a single GET.
      04a5b342
    • Sean McGivern's avatar
      Record whether or not a repository contains ambiguous refs · e0997f1b
      Sean McGivern authored
      A branch can't be a prefix (including a slash) of another branch. For
      instance, you can't have a branch `a` and a branch `a/b`. Same with
      tags. However, you can have a branch `a` and a tag `a/b`, which is
      ambiguous.
      
      In ExtractsRef, we do some work to handle these cases. That can involve
      a fairly slow Redis SMEMBERS call. If a repository has no ambiguous refs
      of this form (which should be the majority), we can perform some
      optimisations.
      
      For the purposes of this method, we only consider refs ambiguous before
      the first slash. If we have a branch `a/b/c` and a tag `a/b`, this
      method won't detect that.
      e0997f1b
  2. 05 Aug, 2020 38 commits