]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/pack-objects-optim-mru'
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Oct 2016 21:03:46 +0000 (14:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Oct 2016 21:03:47 +0000 (14:03 -0700)
"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"

1  2 
builtin/cat-file.c
builtin/pack-objects.c
cache.h
sha1_file.c
streaming.c

index cca97a86c0b1d1029936184f72ed6a20e97da759,8e579980b63888383835140608ef444e92eab8f2..30383e9eb4befb31e0d165d5863615484bcc9da3
@@@ -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;
        }
index 8aeba6a6e1490fb34af374290f923b70002e1c98,977d25f4955b4346bc20471ed35186a2a4b2195e..1e7c2a98a5617b8b42422c22051c5f61b2510751
@@@ -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))
                                *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;
                }
        }
  
diff --cc cache.h
Simple merge
diff --cc sha1_file.c
Simple merge
diff --cc streaming.c
Simple merge