1. 24 8月, 2017 14 次提交
  2. 16 8月, 2017 1 次提交
  3. 12 8月, 2017 2 次提交
  4. 11 8月, 2017 1 次提交
  5. 10 8月, 2017 2 次提交
    • J
      sha1_file: drop experimental GIT_USE_LOOKUP search · f1068efe
      Jeff King 提交于
      Long ago in 628522ec (sha1-lookup: more memory efficient
      search in sorted list of SHA-1, 2007-12-29) we added
      sha1_entry_pos(), a binary search that uses the uniform
      distribution of sha1s to scale the selection of mid-points.
      As this was a performance experiment, we tied it to the
      GIT_USE_LOOKUP environment variable and never enabled it by
      default.
      
      This code was successful in reducing the number of steps in
      each search. But the overhead of the scaling ends up making
      it slower when the cache is warm. Here are best-of-five
      timings for running rev-list on linux.git, which will have
      to look up every object:
      
        $ time git rev-list --objects --all >/dev/null
        real	0m35.357s
        user	0m35.016s
        sys	0m0.340s
      
        $ time GIT_USE_LOOKUP=1 git rev-list --objects --all >/dev/null
        real	0m37.364s
        user	0m37.045s
        sys	0m0.316s
      
      The USE_LOOKUP version might have more benefit on a cold
      cache, as the time to fault in each page would dominate. But
      that would be for a single lookup. In practice, most
      operations tend to look up many objects, and the whole pack
      .idx will end up warm.
      
      It's possible that the code could be better optimized to
      compete with a naive binary search for the warm-cache case,
      and we could have the best of both worlds. But over the
      years nobody has done so, and this is largely dead code that
      is rarely run outside of the test suite. Let's drop it in
      the name of simplicity.
      
      This lets us remove sha1_entry_pos() entirely, as the .idx
      lookup code was the only caller.  Note that sha1-lookup.c
      still contains sha1_pos(), which differs from
      sha1_entry_pos() in two ways:
      
        - it has a different interface; it uses a function pointer
          to access sha1 entries rather than a size/offset pair
          describing the table's memory layout
      
        - it only scales the initial selection of "mi", rather
          than each iteration of the search
      
      We can't get rid of this function, as it's called from
      several places. It may be that we could replace it with a
      simple binary search, but that's out of scope for this patch
      (and would need benchmarking).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f1068efe
    • R
      sha1_file: avoid comparison if no packed hash matches the first byte · 6355a768
      René Scharfe 提交于
      find_pack_entry_one() uses the fan-out table of pack indexes to find out
      which entries match the first byte of the searched hash and does a
      binary search on this subset of the main index table.
      
      If there are no matching entries then lo and hi will have the same
      value.  The binary search still starts and compares the hash of the
      following entry (which has a non-matching first byte, so won't cause any
      trouble), or whatever comes after the sorted list of entries.
      
      The probability of that stray comparison matching by mistake is low, but
      let's not take any chances and check when entering the binary search
      loop if we're actually done already.
      Signed-off-by: NRene Scharfe <l.s.r@web.de>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6355a768
  6. 18 7月, 2017 1 次提交
  7. 01 7月, 2017 1 次提交
    • S
      hashmap.h: compare function has access to a data field · 7663cdc8
      Stefan Beller 提交于
      When using the hashmap a common need is to have access to caller provided
      data in the compare function. A couple of times we abuse the keydata field
      to pass in the data needed. This happens for example in patch-ids.c.
      
      This patch changes the function signature of the compare function
      to have one more void pointer available. The pointer given for each
      invocation of the compare function must be defined in the init function
      of the hashmap and is just passed through.
      
      Documentation of this new feature is deferred to a later patch.
      This is a rather mechanical conversion, just adding the new pass-through
      parameter.  However while at it improve the naming of the fields of all
      compare functions used by hashmaps by ensuring unused parameters are
      prefixed with 'unused_' and naming the parameters what they are (instead
      of 'unused' make it 'unused_keydata').
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7663cdc8
  8. 27 6月, 2017 3 次提交
  9. 25 6月, 2017 2 次提交
  10. 23 6月, 2017 1 次提交
    • R
      sha1_name: cache readdir(3) results in find_short_object_filename() · cc817ca3
      René Scharfe 提交于
      Read each loose object subdirectory at most once when looking for unique
      abbreviated hashes.  This speeds up commands like "git log --pretty=%h"
      considerably, which previously caused one readdir(3) call for each
      candidate, even for subdirectories that were visited before.
      
      The new cache is kept until the program ends and never invalidated.  The
      same is already true for pack indexes.  The inherent racy nature of
      finding unique short hashes makes it still fit for this purpose -- a
      conflicting new object may be added at any time.  Tasks with higher
      consistency requirements should not use it, though.
      
      The cached object names are stored in an oid_array, which is quite
      compact.  The bitmap for remembering which subdir was already read is
      stored as a char array, with one char per directory -- that's not quite
      as compact, but really simple and incurs only an overhead equivalent to
      11 hashes after all.
      Suggested-by: NJeff King <peff@peff.net>
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NRene Scharfe <l.s.r@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cc817ca3
  11. 22 6月, 2017 4 次提交
    • J
      sha1_file: refactor read_object · c84a1f3e
      Jonathan Tan 提交于
      read_object() and sha1_object_info_extended() both implement mechanisms
      such as object replacement, retrying the packed store after failing to
      find the object in the packed store then the loose store, and being able
      to mark a packed object as bad and then retrying the whole process.
      Consolidating these mechanisms would be a great help to maintainability.
      
      Therefore, consolidate them by extending sha1_object_info_extended() to
      support the functionality needed, and then modifying read_object() to
      use sha1_object_info_extended().
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c84a1f3e
    • J
      sha1_file: move delta base cache code up · 845b102b
      Jonathan Tan 提交于
      In a subsequent patch, packed_object_info() will be modified to use the
      delta base cache, so move the relevant code to before
      packed_object_info().
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      845b102b
    • J
      sha1_file: rename LOOKUP_REPLACE_OBJECT · 1f0c0d36
      Jonathan Tan 提交于
      The LOOKUP_REPLACE_OBJECT flag controls whether the
      lookup_replace_object() function is invoked by
      sha1_object_info_extended(), read_sha1_file_extended(), and
      lookup_replace_object_extended(), but it is not immediately clear which
      functions accept that flag.
      
      Therefore restrict this flag to only sha1_object_info_extended(),
      renaming it appropriately to OBJECT_INFO_LOOKUP_REPLACE and adding some
      documentation. Update read_sha1_file_extended() to have a boolean
      parameter instead, and delete lookup_replace_object_extended().
      
      parse_sha1_header() also passes this flag to
      parse_sha1_header_extended() since commit 46f03448 ("sha1_file: support
      reading from a loose object of unknown type", 2015-05-03), but that has
      had no effect since that commit. Therefore this patch also removes this
      flag from that invocation.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1f0c0d36
    • J
      sha1_file: rename LOOKUP_UNKNOWN_OBJECT · 19fc5e84
      Jonathan Tan 提交于
      The LOOKUP_UNKNOWN_OBJECT flag was introduced in commit 46f03448
      ("sha1_file: support reading from a loose object of unknown type",
      2015-05-03) in order to support a feature in cat-file subsequently
      introduced in commit 39e4ae38 ("cat-file: teach cat-file a
      '--allow-unknown-type' option", 2015-05-03). Despite its name and
      location in cache.h, this flag is used neither in
      read_sha1_file_extended() nor in any of the lookup functions, but used
      only in sha1_object_info_extended().
      
      Therefore rename this flag to OBJECT_INFO_ALLOW_UNKNOWN_TYPE, taking the
      name of the cat-file flag that invokes this feature, and move it closer
      to the declaration of sha1_object_info_extended(). Also add
      documentation for this flag.
      
      OBJECT_INFO_ALLOW_UNKNOWN_TYPE is defined to 2, not 1, to avoid
      conflicting with LOOKUP_REPLACE_OBJECT. Avoidance of this conflict is
      necessary because sha1_object_info_extended() supports both flags.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      19fc5e84
  12. 17 6月, 2017 1 次提交
  13. 16 6月, 2017 2 次提交
  14. 14 6月, 2017 2 次提交
  15. 17 4月, 2017 1 次提交
  16. 14 4月, 2017 1 次提交
  17. 02 4月, 2017 1 次提交
    • J
      sha1_loose_object_info: return error for corrupted objects · 93cff9a9
      Jeff King 提交于
      When sha1_loose_object_info() finds that a loose object file
      cannot be stat(2)ed or mmap(2)ed, it returns -1 to signal an
      error to the caller.  However, if it found that the loose
      object file is corrupt and the object data cannot be used
      from it, it stuffs OBJ_BAD into "type" field of the
      object_info, but returns zero (i.e., success), which can
      confuse callers.
      
      This is due to 052fe5ea (sha1_loose_object_info: make type
      lookup optional, 2013-07-12), which switched the return to a
      strict success/error, rather than returning the type (but
      botched the return).
      
      Callers of regular sha1_object_info() don't notice the
      difference, as that function returns the type (which is
      OBJ_BAD in this case). However, direct callers of
      sha1_object_info_extended() see the function return success,
      but without setting any meaningful values in the object_info
      struct, leading them to access potentially uninitialized
      memory.
      
      The easiest way to see the bug is via "cat-file -s", which
      will happily ignore the corruption and report whatever
      value happened to be in the "size" variable.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      93cff9a9