From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>, Jeff King <peff@peff.net>,
Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>
Subject: [PATCH 02/11] pack-bitmap.c: avoid unnecessary `offset_to_pack_pos()`
Date: Wed, 9 Oct 2024 16:31:04 -0400 [thread overview]
Message-ID: <010316f1eb49b46db1ed0b8df10402d3a49013f8.1728505840.git.me@ttaylorr.com> (raw)
In-Reply-To: <cover.1728505840.git.me@ttaylorr.com>
In `try_partial_reuse()`, for any object which is either an OFS_DELTA
or REF_DELTA, we need to determine the bitmap position for its base.
We handle the case of single- and multi-pack bitmaps separately:
- For multi-pack bitmaps, we look to see if the MIDX selected the
base we're looking at to represent that object. If the base object
was selected from a different pack in the MIDX, we won't reuse the
delta.
- For single-pack bitmaps, we convert the base object's offset into
a pack-relative position (identified here as 'base_pos') by
calling `offset_to_pack_pos()`.
But we also call `offset_to_pack_pos()` before handling each case
above separately. For the MIDX case, this is unnecessary, since we
don't need to lookup the base object's pack-relative position;
instead, we just care whether the selected copy of that base is from
the same pack we're currently operating on.
For the non-MIDX case, we end up calling offset_to_pack_pos() again,
yielding the same result, making the earlier call wasteful. This
behavior dates back to 519e17ff75 (pack-bitmap: prepare to mark
objects from multiple packs for reuse, 2023-12-14).
Let's correct that by avoiding the unconditional call to
'offset_to_pack_pos()'.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
pack-bitmap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 706ff26a7b1..5c5c26efe0d 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -2069,7 +2069,6 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git,
if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA) {
off_t base_offset;
- uint32_t base_pos;
uint32_t base_bitmap_pos;
/*
@@ -2085,8 +2084,6 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git,
if (!base_offset)
return 0;
- offset_to_pack_pos(pack->p, base_offset, &base_pos);
-
if (bitmap_is_midx(bitmap_git)) {
/*
* Cross-pack deltas are rejected for now, but could
@@ -2105,6 +2102,8 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git,
return 0;
}
} else {
+ uint32_t base_pos;
+
if (offset_to_pack_pos(pack->p, base_offset,
&base_pos) < 0)
return 0;
--
2.47.0.11.g487258bca34
next prev parent reply other threads:[~2024-10-09 20:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 20:30 [PATCH 00/11] pack-bitmap: convert offset to ref deltas where possible Taylor Blau
2024-10-09 20:31 ` [PATCH 01/11] pack-bitmap.c: do not pass `pack_pos` to `try_partial_reuse()` Taylor Blau
2024-10-09 20:31 ` Taylor Blau [this message]
2024-10-09 20:31 ` [PATCH 03/11] pack-bitmap.c: delay calling 'offset_to_pack_pos()' Taylor Blau
2024-10-09 20:31 ` [PATCH 04/11] pack-bitmap.c: compare `base_offset` to `delta_obj_offset` Taylor Blau
2024-10-09 20:31 ` [PATCH 05/11] pack-bitmap.c: extract `find_base_bitmap_pos()` Taylor Blau
2024-10-09 20:31 ` [PATCH 06/11] pack-bitmap: drop `from_midx` field from `bitmapped_pack` Taylor Blau
2024-10-09 20:31 ` [PATCH 07/11] write_reused_pack_one(): translate bit positions directly Taylor Blau
2024-10-11 8:16 ` Jeff King
2024-11-04 20:36 ` Taylor Blau
2024-10-09 20:31 ` [PATCH 08/11] t5332: enable OFS_DELTAs via test_pack_objects_reused Taylor Blau
2024-10-11 8:19 ` Jeff King
2024-11-04 20:50 ` Taylor Blau
2024-10-09 20:31 ` [PATCH 09/11] pack-bitmap: enable cross-pack delta reuse Taylor Blau
2024-10-11 8:31 ` Jeff King
2024-11-04 21:00 ` Taylor Blau
2024-10-09 20:31 ` [PATCH 10/11] pack-bitmap.c: record whether the result was filtered Taylor Blau
2024-10-11 8:35 ` Jeff King
2024-11-04 21:01 ` Taylor Blau
2024-10-09 20:31 ` [PATCH 11/11] pack-bitmap: enable reusing deltas with base objects in 'haves' bitmap Taylor Blau
2024-10-10 16:46 ` [PATCH 00/11] pack-bitmap: convert offset to ref deltas where possible Junio C Hamano
2024-10-10 17:07 ` Taylor Blau
2024-10-10 20:20 ` Junio C Hamano
2024-10-10 20:32 ` Taylor Blau
2024-10-11 7:54 ` Jeff King
2024-10-11 8:01 ` Jeff King
2024-10-11 16:23 ` Junio C Hamano
2024-10-11 8:38 ` Jeff King
2024-11-19 23:08 ` Taylor Blau
2024-11-19 23:34 ` Taylor Blau
2024-12-18 12:57 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=010316f1eb49b46db1ed0b8df10402d3a49013f8.1728505840.git.me@ttaylorr.com \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).