<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/object-store.h, branch v2.25.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.25.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.25.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-02-14T20:42:27Z</updated>
<entry>
<title>Merge branch 'jt/sha1-file-remove-oi-skip-cached' into maint</title>
<updated>2020-02-14T20:42:27Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-02-14T20:42:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9eddeaece19570d71e5012ecd0271369aaac8797'/>
<id>urn:sha1:9eddeaece19570d71e5012ecd0271369aaac8797</id>
<content type='text'>
has_object_file() said "no" given an object registered to the
system via pretend_object_file(), making it inconsistent with
read_object_file(), causing lazy fetch to attempt fetching an
empty tree from promisor remotes.

* jt/sha1-file-remove-oi-skip-cached:
  sha1-file: remove OBJECT_INFO_SKIP_CACHED
</content>
</entry>
<entry>
<title>sha1-file: remove OBJECT_INFO_SKIP_CACHED</title>
<updated>2020-01-02T20:53:30Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2020-01-02T20:16:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9c8a294a1ae1335511475db9c0eb8841c0ec9738'/>
<id>urn:sha1:9c8a294a1ae1335511475db9c0eb8841c0ec9738</id>
<content type='text'>
In a partial clone, if a user provides the hash of the empty tree ("git
mktree &lt;/dev/null" - for SHA-1, this is 4b825d...) to a command which
requires that that object be parsed, for example:

  git diff-tree 4b825d &lt;a non-empty tree&gt;

then Git will lazily fetch the empty tree, unnecessarily, because
parsing of that object invokes repo_has_object_file(), which does not
special-case the empty tree.

Instead, teach repo_has_object_file() to consult find_cached_object()
(which handles the empty tree), thus bringing it in line with the rest
of the object-store-accessing functions. A cost is that
repo_has_object_file() will now need to oideq upon each invocation, but
that is trivial compared to the filesystem lookup or the pack index
search required anyway. (And if find_cached_object() needs to do more
because of previous invocations to pretend_object_file(), all the more
reason to be consistent in whether we present cached objects.)

As a historical note, the function now known as repo_read_object_file()
was taught the empty tree in 346245a1bb ("hard-code the empty tree
object", 2008-02-13), and the function now known as oid_object_info()
was taught the empty tree in c4d9986f5f ("sha1_object_info: examine
cached_object store too", 2011-02-07). repo_has_object_file() was never
updated, perhaps due to oversight. The flag OBJECT_INFO_SKIP_CACHED,
introduced later in dfdd4afcf9 ("sha1_file: teach
sha1_object_info_extended more flags", 2017-06-26) and used in
e83e71c5e1 ("sha1_file: refactor has_sha1_file_with_flags", 2017-06-26),
was introduced to preserve this difference in empty-tree handling, but
now it can be removed.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>packfile.c: speed up loading lots of packfiles</title>
<updated>2019-12-03T15:59:45Z</updated>
<author>
<name>Colin Stolley</name>
<email>cstolley@runbox.com</email>
</author>
<published>2019-11-27T22:24:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ec48540fe8c387cf7424d5387ddbd53e89bb9d51'/>
<id>urn:sha1:ec48540fe8c387cf7424d5387ddbd53e89bb9d51</id>
<content type='text'>
When loading packfiles on start-up, we traverse the internal packfile
list once per file to avoid reloading packfiles that have already
been loaded. This check runs in quadratic time, so for poorly
maintained repos with a large number of packfiles, it can be pretty
slow.

Add a hashmap containing the packfile names as we load them so that
the average runtime cost of checking for already-loaded packs becomes
constant.

Add a perf test to p5303 to show speed-up.

The existing p5303 test runtimes are dominated by other factors and do
not show an appreciable speed-up. The new test in p5303 clearly exposes
a speed-up in bad cases. In this test we create 10,000 packfiles and
measure the start-up time of git rev-parse, which does little else
besides load in the packs.

Here are the numbers for the new p5303 test:

Test                         HEAD^             HEAD
---------------------------------------------------------------------
5303.12: load 10,000 packs   1.03(0.92+0.10)   0.12(0.02+0.09) -88.3%

Signed-off-by: Colin Stolley &lt;cstolley@runbox.com&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
[jc: squashed the change to call hashmap in install_packed_git() by peff]
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/check-connected-with-alternates'</title>
<updated>2019-07-19T18:30:21Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-07-19T18:30:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=68e65ded5b790bfd8a1072a7f551a8f283f62f29'/>
<id>urn:sha1:68e65ded5b790bfd8a1072a7f551a8f283f62f29</id>
<content type='text'>
The tips of refs from the alternate object store can be used as
starting point for reachability computation now.

* jk/check-connected-with-alternates:
  check_everything_connected: assume alternate ref tips are valid
  object-store.h: move for_each_alternate_ref() from transport.h
</content>
</entry>
<entry>
<title>object-store.h: move for_each_alternate_ref() from transport.h</title>
<updated>2019-07-01T16:47:29Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-07-01T13:17:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=709dfa69908c9448db91a9bcc96941549be6421e'/>
<id>urn:sha1:709dfa69908c9448db91a9bcc96941549be6421e</id>
<content type='text'>
There's nothing inherently transport-related about enumerating the
alternate ref tips. The code has lived in transport.[ch] because the
only use so far had been advertising available tips during transport.
But it could be used for more, and a future patch will teach rev-list to
access these refs.

Let's move it alongside the other alt-odb code, declaring it in
object-store.h with the implementation in sha1-file.c.

This lets us drop the inclusion of transport.h from receive-pack, which
perhaps shows how it was misplaced (though receive-pack is about
transporting objects, transport.h is mostly about the client side).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ds/object-info-for-prefetch-fix'</title>
<updated>2019-06-17T17:15:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-06-17T17:15:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5d5c46b28c04348f7b680e5fe007c6344a86a70a'/>
<id>urn:sha1:5d5c46b28c04348f7b680e5fe007c6344a86a70a</id>
<content type='text'>
Code cleanup and futureproof.

* ds/object-info-for-prefetch-fix:
  sha1-file: split OBJECT_INFO_FOR_PREFETCH
</content>
</entry>
<entry>
<title>sha1-file: split OBJECT_INFO_FOR_PREFETCH</title>
<updated>2019-05-28T20:31:50Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2019-05-28T15:19:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=31f5256c82a36edea3ea2f91e5171e3472878915'/>
<id>urn:sha1:31f5256c82a36edea3ea2f91e5171e3472878915</id>
<content type='text'>
The OBJECT_INFO_FOR_PREFETCH bitflag was added to sha1-file.c in 0f4a4fb1
(sha1-file: support OBJECT_INFO_FOR_PREFETCH, 2019-03-29) and is used to
prevent the fetch_objects() method when enabled.

However, there is a problem with the current use. The definition of
OBJECT_INFO_FOR_PREFETCH is given by adding 32 to OBJECT_INFO_QUICK. This is
clearly stated above the definition (in a comment) that this is so
OBJECT_INFO_FOR_PREFETCH implies OBJECT_INFO_QUICK. The problem is that using
"flag &amp; OBJECT_INFO_FOR_PREFETCH" means that OBJECT_INFO_QUICK also implies
OBJECT_INFO_FOR_PREFETCH.

Split out the single bit from OBJECT_INFO_FOR_PREFETCH into a new
OBJECT_INFO_SKIP_FETCH_OBJECT as the single bit and keep
OBJECT_INFO_FOR_PREFETCH as the union of two flags. This allows a clearer use
of flag checking while also keeping the implication of OBJECT_INFO_QUICK.

Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ds/midx-too-many-packs'</title>
<updated>2019-05-19T07:45:30Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-19T07:45:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=454b419729142cd65466cabdb253d06c3699d098'/>
<id>urn:sha1:454b419729142cd65466cabdb253d06c3699d098</id>
<content type='text'>
The code to generate the multi-pack idx file was not prepared to
see too many packfiles and ran out of open file descriptor, which
has been corrected.

* ds/midx-too-many-packs:
  midx: add packs to packed_git linked list
  midx: pass a repository pointer
</content>
</entry>
<entry>
<title>Merge branch 'dl/no-extern-in-func-decl'</title>
<updated>2019-05-13T14:50:32Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-13T14:50:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4aeeef377347934d6f459e27f7d793de4ce384bb'/>
<id>urn:sha1:4aeeef377347934d6f459e27f7d793de4ce384bb</id>
<content type='text'>
Mechanically and systematically drop "extern" from function
declarlation.

* dl/no-extern-in-func-decl:
  *.[ch]: manually align parameter lists
  *.[ch]: remove extern from function declarations using sed
  *.[ch]: remove extern from function declarations using spatch
</content>
</entry>
<entry>
<title>midx: add packs to packed_git linked list</title>
<updated>2019-05-07T04:48:42Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2019-04-29T16:18:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=af96fe3392fb078cb5447bcb94f2ed8d79d0a4a8'/>
<id>urn:sha1:af96fe3392fb078cb5447bcb94f2ed8d79d0a4a8</id>
<content type='text'>
The multi-pack-index allows searching for objects across multiple
packs using one object list. The original design gains many of
these performance benefits by keeping the packs in the
multi-pack-index out of the packed_git list.

Unfortunately, this has one major drawback. If the multi-pack-index
covers thousands of packs, and a command loads many of those packs,
then we can hit the limit for open file descriptors. The
close_one_pack() method is used to limit this resource, but it
only looks at the packed_git list, and uses an LRU cache to prevent
thrashing.

Instead of complicating this close_one_pack() logic to include
direct references to the multi-pack-index, simply add the packs
opened by the multi-pack-index to the packed_git list. This
immediately solves the file-descriptor limit problem, but requires
some extra steps to avoid performance issues or other problems:

1. Create a multi_pack_index bit in the packed_git struct that is
   one if and only if the pack was loaded from a multi-pack-index.

2. Skip packs with the multi_pack_index bit when doing object
   lookups and abbreviations. These algorithms already check the
   multi-pack-index before the packed_git struct. This has a very
   small performance hit, as we need to walk more packed_git
   structs. This is acceptable, since these operations run binary
   search on the other packs, so this walk-and-ignore logic is
   very fast by comparison.

3. When closing a multi-pack-index file, do not close its packs,
   as those packs will be closed using close_all_packs(). In some
   cases, such as 'git repack', we run 'close_midx()' without also
   closing the packs, so we need to un-set the multi_pack_index bit
   in those packs. This is necessary, and caught by running
   t6501-freshen-objects.sh with GIT_TEST_MULTI_PACK_INDEX=1.

To manually test this change, I inserted trace2 logging into
close_pack_fd() and set pack_max_fds to 10, then ran 'git rev-list
--all --objects' on a copy of the Git repo with 300+ pack-files and
a multi-pack-index. The logs verified the packs are closed as
we read them beyond the file descriptor limit.

Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
