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

[PATCH 0/1] builtin/pack-objects.c: avoid iterating all refs

From
Jacob Vosmaer <jacob@gitlab.com>
Date
Jan 19, 2021, 14:33 UTC
Message-ID
<20210119143348.27535-1-jacob@gitlab.com>

This is a small patch for git-pack-objects which will help server side performance on repositories with lots of refs. I will post a related but slightly larger patch for ls-refs.c in a separate thread.

The back story is in https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/746 but I will try to summarize it here.

We have a particular Gitaly (Git RPC) server at GitLab that has a very homogenous workload, dominated by CI. While trying to reduce CPU utilization on the server we configured CI to fetch with the '--no-tags' option. This had an unexpectedly large impact so I started looking closer at why that may be.

What I learned is that by default, a fetch ends up using the '--include-tag' command line option of git-pack-objects. This causes git-pack-objects to iterate through all the tags of the repository to see if any should be included in the pack because they point to packed objects. The problem is that this "iterate through all the tags" uses for_each_ref which iterates through all references in the repository, and in doing so loads each associated object into memory to check if the ref is broken. But all we need for '--include-tag' is to iterate through refs/tags/.

On the repo we were testing this on, there are about 500,000 refs but only 2,000 tags. So we had to load a lot of objects just for the sake of '--include-tag'. It was common to see more than half the CPU time in git-pack-objects being spent in do_for_each_ref, and that in turn was dominated by ref_resolves_to_object.

So, I think it would be nice to just iterate over those 2,000 tags and not load 500,000 objects outside refs/tags we already know we don't care about.

Jacob Vosmaer (1):
  builtin/pack-objects.c: avoid iterating all refs
 builtin/pack-objects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
-- 
2.30.0
Next: Jacob Vosmaer
Message 1 of 13 in “builtin/pack-objects.c: avoid iterating all refs”
  1. 0/1 builtin/pack-objects.c: avoid iterating all refsJacob Vosmaer, Jan 19, 2021
  2. 1/1 builtin/pack-objects.c: avoid iterating all refsJacob Vosmaer, Jan 19, 2021
  3. Taylor BlauJan 19, 2021
  4. Jeff KingJan 19, 2021
  5. Taylor BlauJan 19, 2021
  6. Jeff KingJan 19, 2021
  7. Ævar Arnfjörð BjarmasonJan 20, 2021
  8. Taylor BlauJan 20, 2021
  9. Ævar Arnfjörð BjarmasonJan 20, 2021
  10. Jeff KingJan 20, 2021
  11. Ævar Arnfjörð BjarmasonJan 21, 2021
  12. Jeff KingJan 21, 2021
  13. Jeff KingJan 19, 2021

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.