diff mbox series

Push a ref to a remote with many refs

Message ID CH2PR11MB429411CA1288526D21C7AF26CF4C0@CH2PR11MB4294.namprd11.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series Push a ref to a remote with many refs | expand

Commit Message

Patrick Marlier (pamarlie) Nov. 19, 2019, 1:12 p.m. UTC
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

Comments

Patrick Marlier (pamarlie) Nov. 25, 2019, 4:22 p.m. UTC | #1
> 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?

Some help on this?

Thanks!
--
Pat
diff mbox series

Patch

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);