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

Re: [PATCH 0/1] pack-bitmap.c: avoid exposing absolute paths

From
Teng Long <dyroneteng@gmail.com>
Date
Nov 2, 2022, 13:52 UTC
Message-ID
<20221102135245.97998-1-tenglong.tl@alibaba-inc.com>
In-Reply-To
<Y2IiSU1L+bJPUioV@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 23 quoted lines
> I mean that later in the process, if we need to find an object we may
> open the .idx file to look for it. So by opening them all up front, we
> _might_ just be doing work that would get done later.
>
> But it's not guaranteed. Imagine you have 10,000 small packs, and one
> big bitmapped pack. If you can serve the request from just the big pack,
> then you'd never need to open those other .idx files at all. However,
> the current code will open them anyway.
>
> I care less about mmap space, and more that it's work (syscalls, and
> examining the contents of the idx) to open each one. It's probably not
> even measurable unless you have a ton of packs, though.
>
> > > So it may not be worth worrying about. It does seem like it would be
> > > easy to reorder open_pack_bitmap_1() to look for a bitmap file first and
> > > only open the idx if it finds something.
> >
> > I think it may be worthy if we have lots of packs and the bitmap is refer to
> > an older one, but I didn't make the test. At least, the scenario is common, I
> > agree with that, so maybe we could shuffle the sort order in "open_pack_bitmap()".
>
> I don't mean the order in which we look at packs. I mean the order of
> operations in open_pack_bitmap_1(), something like:
Thank you for the explanation. Make sense.

I run a test under a repo with 3 packs and without bitmaps,it seems like now will open every idx and failed at last:

➜ pack git:(master) git rev-list --test-bitmap HEAD pack: /Users/tenglong.tl/Downloads/trace-test/.git/objects/pack/pack-c9fe9d2dc5d002d4a4b622626ffa282bcbccb7ee.pack pack: /Users/tenglong.tl/Downloads/trace-test/.git/objects/pack/pack-08841c0c4c1fd176c354bdbd25c5a1b152ea95d0.pack pack: /Users/tenglong.tl/Downloads/trace-test/.git/objects/pack/pack-3cea516b416961285fd8f519e12102b19bcf257e.pack fatal: failed to load bitmap indexes

So we're now looping for packs first, then try to find the corresponded bitmap of it. In that case, why can't we start the search from the bitmap files at first? If this is possible, when we found the first bitmap file or an appropriate one under some mechanism (biggest or newest maybe?I'm not deep into it right now) then break the loop and open it.

Show 29 quoted lines
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index 440407f1be..1df2f6c8b6 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -411,9 +411,6 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
>  	struct stat st;
>  	char *bitmap_name;
>
> -	if (open_pack_index(packfile))
> -		return -1;
> -
>  	bitmap_name = pack_bitmap_filename(packfile);
>  	fd = git_open(bitmap_name);
>
> @@ -438,6 +435,10 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
>  		return -1;
>  	}
>
> +	/* now we know we have a plausible bitmap; make sure the idx is OK, too */
> +	if (open_pack_index(packfile))
> +		return -1;
> +
>  	if (!is_pack_valid(packfile)) {
>  		close(fd);
>  		return -1;
>
> But we can further observe that the first thing is_pack_valid() will do
> is open the idx file. :) So we can really just drop this line entirely,
> I'd think.
I agree that and I think it could append to patch v3, maybe.
Show 9 quoted lines
> BTW, another oddity I noticed in this function. We check:
>
>    if (bitmap_git->pack || bitmap_git->midx) {
> 	   /* ignore extra bitmap file; we can only handle one */
> 	   ...
>    }
>
> but it's impossible for bitmap_git->midx to be set here. If we opened
> the midx bitmap, we'll skip calling open_pack_bitmap() entirely.
Oh, I remember that and it's mentioned in another patchset at Tue, 29 Mar 2022:
https://public-inbox.org/git/20220329024949.62091-1-dyroneteng@gmail.com/

I agree with Taylor with https://public-inbox.org/git/YkPGq0mDL4NG6D1o@nand.local/

But I'm ok if you think it should be solved.
Thank you very much for your help.
Previous: Jeff KingNext: Teng Long
Message 13 of 67 in “pack-bitmap.c: avoid exposing absolute paths”
  1. 0/1 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Aug 26, 2022
  2. 1/1 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Aug 26, 2022
  3. Junio C HamanoAug 26, 2022
  4. Teng LongAug 29, 2022
  5. Taylor BlauOct 26, 2022
  6. Ævar Arnfjörð BjarmasonOct 26, 2022
  7. Teng LongOct 31, 2022
  8. Jeff KingOct 27, 2022
  9. Taylor BlauOct 30, 2022
  10. Teng LongOct 31, 2022
  11. Teng LongNov 2, 2022
  12. Jeff KingNov 2, 2022
  13. Teng LongNov 2, 2022
  14. Teng LongOct 31, 2022
  15. Taylor BlauNov 3, 2022
  16. Ævar Arnfjörð BjarmasonNov 2, 2022
  17. Teng LongNov 2, 2022
  18. 0/1 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 2, 2022
  19. 1/1 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 2, 2022
  20. Taylor BlauNov 3, 2022
  21. Teng LongNov 3, 2022
  22. Taylor BlauNov 5, 2022
  23. Taylor BlauNov 3, 2022
  24. Teng LongNov 3, 2022
  25. 0/2 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 4, 2022
  26. 1/2 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 4, 2022
  27. Taylor BlauNov 4, 2022
  28. 2/2 pack-bitmap.c: remove unnecessary "open_pack_index()" callsTeng Long, Nov 4, 2022
  29. Taylor BlauNov 4, 2022
  30. Taylor BlauNov 4, 2022
  31. 0/2 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 10, 2022
  32. 1/2 pack-bitmap.c: remove unnecessary "open_pack_index()" callsTeng Long, Nov 10, 2022
  33. Jeff KingNov 14, 2022
  34. Taylor BlauNov 14, 2022
  35. Jeff KingNov 14, 2022
  36. Taylor BlauNov 14, 2022
  37. 2/2 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 10, 2022
  38. Taylor BlauNov 11, 2022
  39. Jeff KingNov 14, 2022
  40. Teng LongNov 17, 2022
  41. Jeff KingNov 17, 2022
  42. Taylor BlauNov 17, 2022
  43. Teng LongNov 21, 2022
  44. 0/4 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 21, 2022
  45. 1/4 pack-bitmap.c: remove unnecessary "open_pack_index()" callsTeng Long, Nov 21, 2022
  46. 2/4 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 21, 2022
  47. 3/4 pack-bitmap.c: break out of the bitmap loop early if not tracingTeng Long, Nov 21, 2022
  48. Junio C HamanoNov 21, 2022
  49. Teng LongNov 28, 2022
  50. 4/4 pack-bitmap.c: trace bitmap ignore logs when midx-bitmap is foundTeng Long, Nov 21, 2022
  51. Jeff KingNov 21, 2022
  52. Junio C HamanoNov 21, 2022
  53. Teng LongNov 28, 2022
  54. Teng LongNov 28, 2022
  55. Jeff KingNov 29, 2022
  56. Teng LongNov 29, 2022
  57. Jeff KingNov 21, 2022
  58. Teng LongNov 28, 2022
  59. 0/4 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 28, 2022
  60. 1/4 pack-bitmap.c: remove unnecessary "open_pack_index()" callsTeng Long, Nov 28, 2022
  61. 2/4 pack-bitmap.c: avoid exposing absolute pathsTeng Long, Nov 28, 2022
  62. 3/4 pack-bitmap.c: break out of the bitmap loop early if not tracingTeng Long, Nov 28, 2022
  63. Taylor BlauNov 28, 2022
  64. Teng LongNov 29, 2022
  65. 4/4 pack-bitmap.c: trace bitmap ignore logs when midx-bitmap is foundTeng Long, Nov 28, 2022
  66. Taylor BlauNov 28, 2022
  67. Teng LongNov 29, 2022

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.