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

Push a ref to a remote with many refs

From
PPPatrick Marlier (pamarlie) <pamarlie@cisco.com>
Date
Nov 19, 2019, 13:12 UTC
Message-ID
<CH2PR11MB429411CA1288526D21C7AF26CF4C0@CH2PR11MB4294.namprd11.prod.outlook.com>
Dear git community,

I am hitting a performance issue with "git push <remote> <refspec>". The local repository has only few refs and the remote repository has a lot of refs (1000+) with objects unknown to the local repository.

"git push" of only one refspec takes minutes to complete. A quick analysis shows that a lot of time is spent in the client side. A deeper analysis shows that the client receives the entire list of refs on the remote, then the client is checking in its local repository if the objects exist for all remote refs. Since the local repository has a only few refs, most of the objects are unknown. This issue is particularly amplified because the local repository is using many alternates. Indeed for each unknown object, git will try to find in all alternates too.

To workaround this issue, I ended up skipping the refs that are not part of the push. See patch at the end of the message. Is this safe to do? Is there a better way to do this?

Thanks. Have a nice day,

Author: Patrick Marlier <pamarlie@cisco.com>
Date:   Tue Aug 6 21:40:48 2019 +0200
    send-pack skip if not part of refspec
diff --git a/send-pack.c b/send-pack.c
index 34c77cbb1a..0fe899f753 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -94,7 +94,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
                feed_object(&extra->oid[i], po_in, 1);
 
        while (refs) {
-               if (!is_null_oid(&refs->old_oid))
+               if (!is_null_oid(&refs->old_oid) && !is_null_oid(&refs->new_oid))
                        feed_object(&refs->old_oid, po_in, 1);
                if (!is_null_oid(&refs->new_oid))
                        feed_object(&refs->new_oid, po_in, 0);
Next: Patrick Marlier (pamarlie)
Message 1 of 12 in “Push a ref to a remote with many refs”
  1. Patrick Marlier (pamarlie)Nov 19, 2019
  2. Patrick Marlier (pamarlie)Nov 25, 2019
  3. send-pack: use OBJECT_INFO_QUICK to check negative objectsJeff King, Nov 27, 2019
  4. Patrick Marlier (pamarlie)Nov 29, 2019
  5. Junio C HamanoNov 30, 2019
  6. Jeff KingDec 3, 2019
  7. Jonathan TanDec 4, 2019
  8. Junio C HamanoDec 4, 2019
  9. Jonathan NiederDec 4, 2019
  10. Jeff KingDec 4, 2019
  11. Patrick Marlier (pamarlie)Dec 10, 2019
  12. Jeff KingDec 10, 2019

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.