Skip to content

Commit 5cf7a17

Browse files
peffgitster
authored andcommitted
send-pack: use OBJECT_INFO_QUICK to check negative objects
When pushing, we feed pack-objects a list of both positive and negative objects. The positive objects are what we want to send, and the negative objects are what the other side told us they have, which we can use to limit the size of the push. Before passing along a negative object, send_pack() will make sure we actually have it (since we only know about it because the remote mentioned it, not because it's one of our refs). So it's expected that some of these objects will be missing on the local side. But looking for a missing object is more expensive than one that we have: it triggers reprepare_packed_git() to handle a racy repack, plus it has to explore every alternate's loose object tree (which can be slow if you have a lot of them, or have a high-latency filesystem). This isn't usually a big problem, since repositories you're pushing to don't generally have a large number of refs that are unrelated to what the client has. But there's no reason such a setup is wrong, and it currently performs poorly. We can fix this by using OBJECT_INFO_QUICK, which tells the lookup code that we expect objects to be missing. Notably, it will not re-scan the packs, and it will use the loose cache from 61c7711 (sha1-file: use loose object cache for quick existence check, 2018-11-12). The downside is that in the rare case that we race with a local repack, we might fail to feed some objects to pack-objects, making the resulting push larger. But we'd never produce an invalid or incorrect push, just a less optimal one. That seems like a reasonable tradeoff, and we already do similar things on the fetch side (e.g., when marking COMPLETE commits). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da72936 commit 5cf7a17

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

send-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ int option_parse_push_signed(const struct option *opt,
4141
static void feed_object(const struct object_id *oid, FILE *fh, int negative)
4242
{
4343
if (negative &&
44-
!has_object_file_with_flags(oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
44+
!has_object_file_with_flags(oid,
45+
OBJECT_INFO_SKIP_FETCH_OBJECT |
46+
OBJECT_INFO_QUICK))
4547
return;
4648

4749
if (negative)

0 commit comments

Comments
 (0)