1
0
mirror of https://github.com/git/git.git synced 2024-10-21 13:59:03 +02:00
git/builtin
Jeff King b495697b82 fetch-pack: avoid repeatedly re-scanning pack directory
When we look up a sha1 object for reading via parse_object() =>
read_sha1_file() => read_object() callpath, we first check
packfiles, and then loose objects. If we still haven't found it, we
re-scan the list of packfiles in `objects/pack`. This final step
ensures that we can co-exist with a simultaneous repack process
which creates a new pack and then prunes the old object.

This extra re-scan usually does not have a performance impact for
two reasons:

  1. If an object is missing, then typically the re-scan will find a
     new pack, then no more misses will occur.  Or if it truly is
     missing, then our next step is usually to die().

  2. Re-scanning is cheap enough that we do not even notice.

However, these do not always hold. The assumption in (1) is that the
caller is expecting to find the object. This is usually the case,
but the call to `parse_object` in `everything_local` does not follow
this pattern. It is looking to see whether we have objects that the
remote side is advertising, not something we expect to
have. Therefore if we are fetching from a remote which has many refs
pointing to objects we do not have, we may end up re-scanning the
pack directory many times.

Even with this extra re-scanning, the impact is often not noticeable
due to (2); we just readdir() the packs directory and skip any packs
that are already loaded. However, if there are a large number of
packs, even enumerating the directory can be expensive, especially
if we do it repeatedly.

Having this many packs is a good sign the user should run `git gc`,
but it would still be nice to avoid having to scan the directory at
all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-26 19:37:30 -08:00
..
add.c Merge branch 'ar/clone-honor-umask-at-top' into maint 2012-07-22 13:04:05 -07:00
annotate.c
apply.c Merge branch 'maint-1.7.11' into maint 2012-09-12 14:08:05 -07:00
archive.c
bisect--helper.c
blame.c Merge branch 'jc/maint-blame-no-such-path' into maint 2012-09-24 12:40:02 -07:00
branch.c
bundle.c
cat-file.c Merge branch 'maint-1.7.11' into maint 2012-09-10 15:31:06 -07:00
check-attr.c Add missing -z to git check-attr usage text for consistency with man page 2012-09-17 13:45:32 -07:00
check-ref-format.c
checkout-index.c
checkout.c Sync with 1.7.11.6 2012-09-11 11:23:54 -07:00
clean.c
clone.c Merge branch 'rt/maint-clone-single' into maint 2012-10-08 11:34:02 -07:00
column.c
commit-tree.c Merge branch 'kk/maint-commit-tree' 2012-07-23 20:55:54 -07:00
commit.c Merge branch 'os/commit-submodule-ignore' into maint 2012-10-08 11:34:34 -07:00
config.c Merge branch 'jk/config-warn-on-inaccessible-paths' into maint 2012-09-18 14:24:06 -07:00
count-objects.c
credential.c
describe.c
diff-files.c
diff-index.c
diff-tree.c
diff.c Merge branch 'tr/void-diff-setup-done' into maint-1.7.11 2012-09-11 10:53:40 -07:00
fast-export.c
fetch-pack.c fetch-pack: avoid repeatedly re-scanning pack directory 2013-01-26 19:37:30 -08:00
fetch.c fetch: run gc --auto after fetching 2013-01-26 19:25:38 -08:00
fmt-merge-msg.c
for-each-ref.c for-each-ref: Fix sort with multiple keys 2012-08-21 14:42:12 -07:00
fsck.c
gc.c
grep.c Merge branch 'jc/maint-log-grep-all-match-1' into maint 2012-09-29 22:30:56 -07:00
hash-object.c
help.c
index-pack.c
init-db.c
log.c Merge branch 'mz/cherry-pick-cmdline-order' into maint 2012-09-14 21:24:18 -07:00
ls-files.c
ls-remote.c ls-remote: document the '--get-url' option 2012-09-07 10:58:35 -07:00
ls-tree.c
mailinfo.c Merge branch 'lt/mailinfo-handle-attachment-more-sanely' into maint 2012-10-08 11:33:00 -07:00
mailsplit.c
merge-base.c
merge-file.c
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c
merge.c Merge branch 'tr/void-diff-setup-done' into maint-1.7.11 2012-09-11 10:53:40 -07:00
mktag.c
mktree.c
mv.c
name-rev.c
notes.c
pack-objects.c
pack-redundant.c
pack-refs.c
patch-id.c
prune-packed.c
prune.c prune.c: only print informational message in show_only or verbose mode 2012-08-07 15:01:37 -07:00
push.c
read-tree.c
receive-pack.c receive-pack: drop "n/a" on unpacker errors 2012-09-21 09:50:13 -07:00
reflog.c
remote-ext.c
remote-fd.c
remote.c remote: prefer subcommand name 'remove' to 'rm' 2012-09-06 13:23:22 -07:00
replace.c
rerere.c
reset.c
rev-list.c
rev-parse.c Merge branch 'maint-1.7.11' into maint 2012-09-12 14:08:05 -07:00
revert.c cherry-pick/revert: respect order of revisions to pick 2012-08-30 14:00:23 -07:00
rm.c
send-pack.c do not send client agent unless server does first 2012-08-10 12:35:13 -07:00
shortlog.c
show-branch.c
show-ref.c
stripspace.c
symbolic-ref.c
tag.c
tar-tree.c
unpack-file.c
unpack-objects.c
update-index.c
update-ref.c
update-server-info.c
upload-archive.c
var.c
verify-pack.c
verify-tag.c
write-tree.c