summaryrefslogtreecommitdiff
path: root/builtin/pack-objects.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2020-07-21 00:21:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-21 21:29:42 (GMT)
commite00549aa9b19cc85c8bf3c3efd0a466aaf5e08f3 (patch)
treef3b64ea70370441755d6d3ee36cf101782af3ecd /builtin/pack-objects.c
parent8d5cf957352badca4575cc85c020d6cf73db86f7 (diff)
downloadgit-e00549aa9b19cc85c8bf3c3efd0a466aaf5e08f3.zip
git-e00549aa9b19cc85c8bf3c3efd0a466aaf5e08f3.tar.gz
git-e00549aa9b19cc85c8bf3c3efd0a466aaf5e08f3.tar.bz2
pack-objects: prefetch objects to be packed
When an object to be packed is noticed to be missing, prefetch all to-be-packed objects in one batch. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r--builtin/pack-objects.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index e09d140..ecef5cd 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -35,6 +35,7 @@
#include "midx.h"
#include "trace2.h"
#include "shallow.h"
+#include "promisor-remote.h"
#define IN_PACK(obj) oe_in_pack(&to_pack, obj)
#define SIZE(obj) oe_size(&to_pack, obj)
@@ -1704,7 +1705,26 @@ static int can_reuse_delta(const struct object_id *base_oid,
return 0;
}
-static void check_object(struct object_entry *entry)
+static void prefetch_to_pack(uint32_t object_index_start) {
+ struct oid_array to_fetch = OID_ARRAY_INIT;
+ uint32_t i;
+
+ for (i = object_index_start; i < to_pack.nr_objects; i++) {
+ struct object_entry *entry = to_pack.objects + i;
+
+ if (!oid_object_info_extended(the_repository,
+ &entry->idx.oid,
+ NULL,
+ OBJECT_INFO_FOR_PREFETCH))
+ continue;
+ oid_array_append(&to_fetch, &entry->idx.oid);
+ }
+ promisor_remote_get_direct(the_repository,
+ to_fetch.oid, to_fetch.nr);
+ oid_array_clear(&to_fetch);
+}
+
+static void check_object(struct object_entry *entry, uint32_t object_index)
{
unsigned long canonical_size;
enum object_type type;
@@ -1843,8 +1863,16 @@ static void check_object(struct object_entry *entry)
}
if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
- OBJECT_INFO_LOOKUP_REPLACE) < 0)
- type = -1;
+ OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
+ if (has_promisor_remote()) {
+ prefetch_to_pack(object_index);
+ if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
+ OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
+ type = -1;
+ } else {
+ type = -1;
+ }
+ }
oe_set_type(entry, type);
if (entry->type_valid) {
SET_SIZE(entry, canonical_size);
@@ -2065,7 +2093,7 @@ static void get_object_details(void)
for (i = 0; i < to_pack.nr_objects; i++) {
struct object_entry *entry = sorted_by_offset[i];
- check_object(entry);
+ check_object(entry, i);
if (entry->type_valid &&
oe_size_greater_than(&to_pack, entry, big_file_threshold))
entry->no_try_delta = 1;