<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/pack-bitmap.c, branch v2.21.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.21.2</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.21.2'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2018-11-12T05:50:06Z</updated>
<entry>
<title>pack-*.c: remove the_repository references</title>
<updated>2018-11-12T05:50:06Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2018-11-10T05:49:08Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=7c14112741b81366cfbbc3b98e0b92422fcce83d'/>
<id>urn:sha1:7c14112741b81366cfbbc3b98e0b92422fcce83d</id>
<content type='text'>
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/pack-objects-with-bitmap-fix'</title>
<updated>2018-09-17T20:53:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-09-17T20:53:58Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=b4583001b4387b454b5afffebb8b350fca291393'/>
<id>urn:sha1:b4583001b4387b454b5afffebb8b350fca291393</id>
<content type='text'>
Hotfix of the base topic.

* jk/pack-objects-with-bitmap-fix:
  pack-bitmap: drop "loaded" flag
  traverse_bitmap_commit_list(): don't free result
  t5310: test delta reuse with bitmaps
  bitmap_has_sha1_in_uninteresting(): drop BUG check
</content>
</entry>
<entry>
<title>Merge branch 'jk/pack-delta-reuse-with-bitmap'</title>
<updated>2018-09-17T20:53:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-09-17T20:53:53Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=3ebdef2e1b4c89fd193140b36c04b41eb7f9a86d'/>
<id>urn:sha1:3ebdef2e1b4c89fd193140b36c04b41eb7f9a86d</id>
<content type='text'>
When creating a thin pack, which allows objects to be made into a
delta against another object that is not in the resulting pack but
is known to be present on the receiving end, the code learned to
take advantage of the reachability bitmap; this allows the server
to send a delta against a base beyond the "boundary" commit.

* jk/pack-delta-reuse-with-bitmap:
  pack-objects: reuse on-disk deltas for thin "have" objects
  pack-bitmap: save "have" bitmap from walk
  t/perf: add perf tests for fetches from a bitmapped server
  t/perf: add infrastructure for measuring sizes
  t/perf: factor out percent calculations
  t/perf: factor boilerplate out of test_perf
</content>
</entry>
<entry>
<title>pack-bitmap: drop "loaded" flag</title>
<updated>2018-09-04T15:40:14Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-09-01T07:50:57Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=199c86be1623ab5053b4ed0ce6ed2ae974e3e859'/>
<id>urn:sha1:199c86be1623ab5053b4ed0ce6ed2ae974e3e859</id>
<content type='text'>
In the early days of the bitmap code, there was a single
static bitmap_index struct that was used behind the scenes,
and any bitmap-related functions could lazily check
bitmap_git.loaded to see if they needed to read the on-disk
data.

But since 3ae5fa0768 (pack-bitmap: remove bitmap_git global
variable, 2018-06-07), the caller is responsible for the
lifetime of the bitmap_index struct, and we return it from
prepare_bitmap_git() and prepare_bitmap_walk(), both of
which load the on-disk data (or return NULL).

So outside of these functions, it's not possible to have a
bitmap_index for which the loaded flag is not true. Nor is
it possible to accidentally pass an already-loaded
bitmap_index to the loading function (which is static-local
to the file).

We can drop this unnecessary and confusing flag.

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>traverse_bitmap_commit_list(): don't free result</title>
<updated>2018-09-04T15:40:12Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-09-01T07:49:48Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=715d0c50e1ba479290d9fcb34119d8f9a09bfed3'/>
<id>urn:sha1:715d0c50e1ba479290d9fcb34119d8f9a09bfed3</id>
<content type='text'>
Since it was introduced in fff42755ef (pack-bitmap: add
support for bitmap indexes, 2013-12-21), this function has
freed the result after traversing it. That is an artifact of
the early days of the bitmap code, when we had a single
static "struct bitmap_index". Back then, it was intended
that you would do:

  prepare_bitmap_walk(&amp;revs);
  traverse_bitmap_commit_list(&amp;revs);

Since the actual bitmap_index struct was totally behind the
scenes, it was convenient for traverse_bitmap_commit_list()
to clean it up, clearing the way for another traversal.

But since 3ae5fa0768 (pack-bitmap: remove bitmap_git global
variable, 2018-06-07), the caller explicitly manages the
bitmap_index struct itself, like this:

  b = prepare_bitmap_walk(&amp;revs);
  traverse_bitmap_commit_list(b, &amp;revs);
  free_bitmap_index(b);

It no longer makes sense to auto-free the result after the
traversal. If you want to do another traversal, you'd just
create a new bitmap_index. And while nobody tries to call
traverse_bitmap_commit_list() twice, the fact that it throws
away the result might be surprising, and is better avoided.

Note that in the "old" way it was possible for two walks to
amortize the cost of opening the on-disk .bitmap file (since
it was stored in the global bitmap_index), but we lost that
in 3ae5fa0768. However, no code actually does this, so it's
not worth addressing now. The solution might involve a new:

  reset_bitmap_walk(b, &amp;revs);

call. Or we might even attach the bitmap data to its
matching packed_git struct, so that multiple
prepare_bitmap_walk() calls could use it. That can wait
until somebody actually has need of the optimization (and
until then, we'll do the correct, unsurprising thing).

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>bitmap_has_sha1_in_uninteresting(): drop BUG check</title>
<updated>2018-09-04T15:30:48Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-09-01T07:44:48Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=5476fb07ebcf389752acef0a894a1eea1ff13ea9'/>
<id>urn:sha1:5476fb07ebcf389752acef0a894a1eea1ff13ea9</id>
<content type='text'>
Commit 30cdc33fba (pack-bitmap: save "have" bitmap from
walk, 2018-08-21) introduced a new function for looking at
the "have" side of a bitmap walk. Because it only makes
sense to do so after we've finished the walk, we added an
extra safety assertion, making sure that bitmap_git-&gt;result
is non-NULL.

However, this safety is misguided. It was trying to catch
the case where we had called prepare_bitmap_walk() to give
us a "struct bitmap_index", but had not yet called
traverse_bitmap_commit_list() to walk it. But all of the
interesting computation (including setting up the result and
"have" bitmaps) happens in the first function! The latter
function only delivers the result to a callback function.

So the case we were worried about is impossible; if you get
a non-NULL result from prepare_bitmap_walk(), then its
"have" field will be fully formed.

But much worse, traverse_bitmap_commit_list() actually frees
the result field as it finishes. Which means that this
assertion is worse than useless: it's almost guaranteed to
trigger!

Our test suite didn't catch this because the function isn't
actually exercised at all. The only caller comes from
6a1e32d532 (pack-objects: reuse on-disk deltas for thin
"have" objects, 2018-08-21), and that's triggered only when
you fetch or push history that contains an object with a
base that is found deep in history. Our test suite fetches
and pushes either don't use bitmaps, or use too-small
example repositories. But any reasonably-sized real-world
push or fetch (with bitmaps) would trigger this.

This patch drops the harmful assertion and tweaks the
docstring for the function to make the precondition clear.
The tests need to be improved to exercise this new
pack-objects feature, but we'll do that in a separate
commit.

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>pack-bitmap: save "have" bitmap from walk</title>
<updated>2018-08-21T19:33:39Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-08-21T19:07:01Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=30cdc33fba361528c317042535fad9d5f0a2c6e6'/>
<id>urn:sha1:30cdc33fba361528c317042535fad9d5f0a2c6e6</id>
<content type='text'>
When we do a bitmap walk, we save the result, which
represents (WANTs &amp; ~HAVEs); i.e., every object we care
about visiting in our walk. However, we throw away the
haves bitmap, which can sometimes be useful, too. Save it
and provide an access function so code which has performed a
walk can query it.

A few notes on the accessor interface:

 - the bitmap code calls these "haves" because it grew out
   of the want/have negotiation for fetches. But really,
   these are simply the objects that would be flagged
   UNINTERESTING in a regular traversal. Let's use that
   more universal nomenclature for the external module
   interface. We may want to change the internal naming
   inside the bitmap code, but that's outside the scope of
   this patch.

 - it still uses a bare "sha1" rather than "oid". That's
   true of all of the bitmap code. And in this particular
   instance, our caller in pack-objects is dealing with the
   bare sha1 that comes from a packed REF_DELTA (we're
   pointing directly to the mmap'd pack on disk). That's
   something we'll have to deal with as we transition to a
   new hash, but we can wait and see how the caller ends up
   being fixed and adjust this interface accordingly.

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>treewide: use get_all_packs</title>
<updated>2018-08-20T22:31:40Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2018-08-20T16:52:04Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=454ea2e4d7036862e8b2f69ef2dea640f8787510'/>
<id>urn:sha1:454ea2e4d7036862e8b2f69ef2dea640f8787510</id>
<content type='text'>
There are many places in the codebase that want to iterate over
all packfiles known to Git. The purposes are wide-ranging, and
those that can take advantage of the multi-pack-index already
do. So, use get_all_packs() instead of get_packed_git() to be
sure we are iterating over all packfiles.

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>pack-bitmap: add free function</title>
<updated>2018-06-21T19:22:48Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2018-06-07T19:04:14Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=f3c23db2d7e764b247f7d76a8d0ba180811e9525'/>
<id>urn:sha1:f3c23db2d7e764b247f7d76a8d0ba180811e9525</id>
<content type='text'>
Add a function to free struct bitmap_index instances, and use it where
needed (except when rebuild_existing_bitmaps() is used, since it creates
references to the bitmaps within the struct bitmap_index passed to it).

Note that the hashes field in struct bitmap_index is not freed because
it points to another field within the same struct. The documentation for
that field has been updated to clarify that.

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>pack-bitmap: remove bitmap_git global variable</title>
<updated>2018-06-21T18:17:39Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2018-06-07T19:04:13Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=3ae5fa0768f7f9781b40b1d40cb2f9f4c753bad4'/>
<id>urn:sha1:3ae5fa0768f7f9781b40b1d40cb2f9f4c753bad4</id>
<content type='text'>
Remove the bitmap_git global variable. Instead, generate on demand an
instance of struct bitmap_index for code that needs to access it.

This allows us significant control over the lifetime of instances of
struct bitmap_index. In particular, packs can now be closed without
worrying if an unnecessarily long-lived "pack" field in struct
bitmap_index still points to it.

The bitmap API is also clearer in that we need to first obtain a struct
bitmap_index, then we use it.

This patch raises two potential issues: (1) memory for the struct
bitmap_index is allocated without being freed, and (2)
prepare_bitmap_git() and prepare_bitmap_walk() can reuse a previously
loaded bitmap. For (1), this will be dealt with in a subsequent patch in
this patch set that also deals with freeing the contents of the struct
bitmap_index (which were not freed previously, because they have global
scope). For (2), current bitmap users only load the bitmap once at most
(note that pack-objects can use bitmaps or write bitmaps, but not both
at the same time), so support for reuse has no effect - and future users
can pass around the struct bitmap_index * obtained if they need to do 2
or more things with the same bitmap.

Helped-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
