git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git fetch slow on local repository with 600k refs

From
Sean Allred <allred.sean@gmail.com>
Date
Mar 14, 2023, 14:29 UTC
Message-ID
<m0wn3jxu7g.fsf@epic96565.epic.com>
In-Reply-To
<e28a23e8eb044d26947462b8619e88bd@xiaomi.com>
程洋 <chengyang@xiaomi.com> writes:
Show 14 quoted lines
> We're holding a Gerrit server cluster. And uses pull-replication
> plugin to sync changes between master and slave.
>
> When a change is pushed to master, it notify the slave, and slave
> fetch it from master.
>
> But we found in a big repository with 600k refs. Fetch takes 5-10
> seconds even if fetching a 1 byte change. Here is the GIT_TRACE2_PERF
>
> I did an experiment to fetch a ref that my slave already have. And we
> can find git rev-list takes 2 seconds to perform. (I guess it try to
> find remote object from reachable objects of local refs one by one)
>
> Is there anyway to optimize such situation?

Do you need all those refs as refs -- or are you just looking to keep the commits?

We found a rather clever solution for the latter we're looking to upstream at some point to collect all refs into a single 'archive' ref that collects commits in fake merge commits (there's no actual conflict resolution happening -- we just use the same tree over and over). We make each commit message look like show-ref output. For example:

A single ref (refs/archive) pointing to commit (A), with contents
    tree <some arbitrary tree>
    parent <B> [... 500 other commits 'merged' in ...]
    author <system user>
    committer <system user>
    deadbeef0123456788... refs/tags/very/old/release-1
    deadbeef0123456789... refs/tags/very/old/release-2

When we want to pull a ref out of the archive, we have a process in place to do so. This keeps the total number of refs down and the fetch/push performance within acceptable limits.

-- Sean Allred

Previous: 程洋
Message 4 of 4 in “Git fetch slow on local repository with 600k refs”
  1. 程洋Mar 13, 2023
  2. Bagas SanjayaMar 14, 2023
  3. 程洋Mar 14, 2023
  4. Sean AllredMar 14, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.