HomePhabricator

Improve performance of repository discovery in repositories with >65K refs

Description

Improve performance of repository discovery in repositories with >65K refs

Summary:
Ref T13593. The commit cache in this Engine has a maximum fixed size (currently 65,535 entries).

If we execute discovery in a repository with more refs than this (e.g., 180K), we get fast lookups for the first 65,535 refs and slow lookups for the remaining refs.

Instead, divide the refs into chunks no larger than the cache size, and perform an explicit cache fill before each chunk is processed.

Test Plan:

  • Created a repository with 1K refs. Set cache size to 256. Ran discovery.
    • Before patch: saw one large cache fill and then ~750 single-gets.
    • After patch: saw four large cache fills.
  • Compared bin/repository discover ... --verbose output before and after patch for overall effect; saw no differences.

Maniphest Tasks: T13593

Differential Revision: https://secure.phabricator.com/D21521