git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/5] pack-bitmap.c: avoid repeated `pack_pos_to_offset()` during reuse

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 4, 2024, 18:54 UTC
Message-ID
<xmqq1q1z9rmt.fsf@gitster.g>
In-Reply-To
<afa25c8806b0e80f1d3ed46f29eb164cab4583ac.1724793201.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 17 quoted lines
> @@ -2055,17 +2055,18 @@ static int try_partial_reuse(struct bitmap_index *bitmap_git,
>  			     struct bitmapped_pack *pack,
>  			     size_t bitmap_pos,
>  			     uint32_t pack_pos,
> +			     off_t offset,
>  			     struct bitmap *reuse,
>  			     struct pack_window **w_curs)
>  {
> -	off_t offset, delta_obj_offset;
> +	off_t delta_obj_offset;
>  	enum object_type type;
>  	unsigned long size;
>  
>  	if (pack_pos >= pack->p->num_objects)
>  		return -1; /* not actually in the pack */
>  
> -	offset = delta_obj_offset = pack_pos_to_offset(pack->p, pack_pos);

We are now passing redundant piece of information "offset" that could be derived from two other parameters, which feels a bit icky,

I suspect that try_partial_reuse() can be taught not to require pack_pos and instead work entirely on offset

 - The caller can pass a very large offset to represent "not
   actually in the pack" early return condition.
 - The logic to punt on a delta pointing backwards can be done by
   comparing the base_offset and offset, instead of comparing the
   base_pos and pack_pos.

but it may not be worth the effort, unless we are going to do similar clean-up globally in all the codepaths that access packfiles.

Thanks.
Previous: Taylor BlauNext: Taylor Blau
Message 11 of 17 in “pack-objects: brown-paper-bag fixes for multi-pack reuse”
  1. 0/5 pack-objects: brown-paper-bag fixes for multi-pack reuseTaylor Blau, Aug 27, 2024
  2. 1/5 t/t5332-multi-pack-reuse.sh: verify pack generation with --strictTaylor Blau, Aug 27, 2024
  3. 2/5 pack-bitmap: tag bitmapped packs with their corresponding MIDXTaylor Blau, Aug 27, 2024
  4. Junio C HamanoAug 28, 2024
  5. Taylor BlauAug 29, 2024
  6. Jeff KingSep 5, 2024
  7. Taylor BlauSep 17, 2024
  8. 3/5 builtin/pack-objects.c: translate bit positions during pack-reuseTaylor Blau, Aug 27, 2024
  9. Junio C HamanoSep 4, 2024
  10. 4/5 pack-bitmap.c: avoid repeated `pack_pos_to_offset()` during reuseTaylor Blau, Aug 27, 2024
  11. Junio C HamanoSep 4, 2024
  12. Taylor BlauSep 4, 2024
  13. 5/5 builtin/pack-objects.c: do not open-code `MAX_PACK_OBJECT_HEADER`Taylor Blau, Aug 27, 2024
  14. Junio C HamanoSep 4, 2024
  15. Taylor BlauSep 4, 2024
  16. Jeff KingSep 5, 2024
  17. Junio C HamanoSep 5, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.