Merge branch 'jt/bulk-prefetch'

"git read-tree" had a codepath where blobs are fetched one-by-one
from the promisor remote, which has been corrected to fetch in bulk.

* jt/bulk-prefetch:
  cache-tree: prefetch in partial clone read-tree
  unpack-trees: refactor prefetching code
This commit is contained in:
Junio C Hamano
2021-08-02 14:06:42 -07:00
5 changed files with 82 additions and 21 deletions

View File

@ -27,6 +27,7 @@
#include "progress.h"
#include "sparse-index.h"
#include "csum-file.h"
#include "promisor-remote.h"
/* Mask for the name length in ce_flags in the on-disk index */
@ -3663,3 +3664,25 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta
strbuf_add(sb, &buffer, sizeof(uint32_t));
}
}
void prefetch_cache_entries(const struct index_state *istate,
must_prefetch_predicate must_prefetch)
{
int i;
struct oid_array to_fetch = OID_ARRAY_INIT;
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce = istate->cache[i];
if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
continue;
if (!oid_object_info_extended(the_repository, &ce->oid,
NULL,
OBJECT_INFO_FOR_PREFETCH))
continue;
oid_array_append(&to_fetch, &ce->oid);
}
promisor_remote_get_direct(the_repository,
to_fetch.oid, to_fetch.nr);
oid_array_clear(&to_fetch);
}