From: Junio C Hamano Date: Mon, 10 Oct 2016 21:03:46 +0000 (-0700) Subject: Merge branch 'jk/pack-objects-optim-mru' X-Git-Tag: v2.11.0-rc0~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6e24c94df9df6d39f2316113c14fe07d2ab03d7;p=thirdparty%2Fgit.git Merge branch 'jk/pack-objects-optim-mru' "git pack-objects" in a repository with many packfiles used to spend a lot of time looking for/at objects in them; the accesses to the packfiles are now optimized by checking the most-recently-used packfile first. * jk/pack-objects-optim-mru: pack-objects: use mru list when iterating over packs pack-objects: break delta cycles before delta-search phase sha1_file: make packed_object_info public provide an initializer for "struct object_info" --- e6e24c94df9df6d39f2316113c14fe07d2ab03d7 diff --cc builtin/cat-file.c index cca97a86c0,8e579980b6..30383e9eb4 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@@ -53,10 -28,9 +53,10 @@@ static int cat_one_file(int opt, const char *buf; unsigned long size; struct object_context obj_context; - struct object_info oi = {NULL}; + struct object_info oi = OBJECT_INFO_INIT; struct strbuf sb = STRBUF_INIT; unsigned flags = LOOKUP_REPLACE_OBJECT; + const char *path = force_path; if (unknown_type) flags |= LOOKUP_UNKNOWN_OBJECT; @@@ -445,12 -376,9 +445,11 @@@ static int batch_objects(struct batch_o data.mark_query = 1; strbuf_expand(&buf, opt->format, expand_format, &data); data.mark_query = 0; + if (opt->cmdmode) + data.split_on_whitespace = 1; if (opt->all_objects) { - struct object_info empty; - memset(&empty, 0, sizeof(empty)); + struct object_info empty = OBJECT_INFO_INIT; if (!memcmp(&data.info, &empty, sizeof(empty))) data.skip_object_info = 1; } diff --cc builtin/pack-objects.c index 8aeba6a6e1,977d25f495..1e7c2a98a5 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@@ -994,31 -958,17 +995,32 @@@ static int want_object_in_pack(const un struct packed_git **found_pack, off_t *found_offset) { - struct packed_git *p; + struct mru_entry *entry; + int want; if (!exclude && local && has_loose_object_nonlocal(sha1)) return 0; - *found_pack = NULL; - *found_offset = 0; + /* + * If we already know the pack object lives in, start checks from that + * pack - in the usual case when neither --local was given nor .keep files + * are present we will determine the answer right now. + */ + if (*found_pack) { + want = want_found_object(exclude, *found_pack); + if (want != -1) + return want; + } - for (p = packed_git; p; p = p->next) { + for (entry = packed_git_mru->head; entry; entry = entry->next) { + struct packed_git *p = entry->item; - off_t offset = find_pack_entry_one(sha1, p); + off_t offset; + + if (p == *found_pack) + offset = *found_offset; + else + offset = find_pack_entry_one(sha1, p); + if (offset) { if (!*found_pack) { if (!is_pack_valid(p)) @@@ -1026,9 -976,33 +1028,11 @@@ *found_offset = offset; *found_pack = p; } - if (exclude) - return 1; - if (incremental) - return 0; - - /* - * When asked to do --local (do not include an - * object that appears in a pack we borrow - * from elsewhere) or --honor-pack-keep (do not - * include an object that appears in a pack marked - * with .keep), we need to make sure no copy of this - * object come from in _any_ pack that causes us to - * omit it, and need to complete this loop. When - * neither option is in effect, we know the object - * we just found is going to be packed, so break - * out of the loop to return 1 now. - */ - if (!ignore_packed_keep && - (!local || !have_non_local_packs)) { + want = want_found_object(exclude, p); ++ if (!exclude && want > 0) + mru_mark(packed_git_mru, entry); - break; - } - - if (local && !p->pack_local) - return 0; - if (ignore_packed_keep && p->pack_local && p->pack_keep) - return 0; + if (want != -1) + return want; } }