[PATCH] cache-tree: avoid needless promisor object fetch
- From
- Jonathan Tan <jonathantanmy@google.com>
- Date
- Apr 23, 2021, 03:16 UTC
- Message-ID
- <20210423031659.2362659-1-jonathantanmy@google.com>
In update_one() (used only by cache_tree_update()), there is an object existence check that, if it fails, will automatically trigger a lazy fetch in a partial clone. But the fetch is not necessary - the object is not actually being used.
Replace that check with two checks: an object existence check that does not fetch, and then a check that that object is a promisor object.
Doing this avoids multiple lazy fetches when merging two trees in a partial clone, as noticed at $DAYJOB.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com> --- Another alternative is to think about whether the object existence check here is needed in the first place.
There might also be other places we can make a similar change in update_one(), but I limited myself to what's needed to solve the specific case we discovered at $DAYJOB. --- cache-tree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/cache-tree.c b/cache-tree.c index add1f07713..6728722597 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -6,6 +6,7 @@ #include "object-store.h" #include "replace-object.h" #include "promisor-remote.h" +#include "packfile.h" #ifndef DEBUG_CACHE_TREE #define DEBUG_CACHE_TREE 0 @@ -362,7 +363,9 @@ static int update_one(struct cache_tree *it, (has_promisor_remote() && ce_skip_worktree(ce)); if (is_null_oid(oid) || - (!ce_missing_ok && !has_object_file(oid))) { + (!ce_missing_ok && + !has_object_file_with_flags(oid, OBJECT_INFO_SKIP_FETCH_OBJECT) && + !is_promisor_object(oid))) { strbuf_release(&buffer); if (expected_missing) return -1;
-- 2.31.1.498.g6c1eba8ee3d-goog