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

Re: [PATCH 1/2] pack-bitmap: remove bitmap_git global variable

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jun 11, 2018, 18:50 UTC
Message-ID
<20180611115046.d03f8093347dc6c0e9b116fc@google.com>
In-Reply-To
<20180609060437.GA30224@sigill.intra.peff.net>

On Sat, 9 Jun 2018 02:04:38 -0400 Jeff King <peff@peff.net> wrote:

Show 5 quoted lines
> This function used to be idempotent, so any code which wanted to use the
> global bitmap_git could call it "just in case". After your patch, it's
> not. I think it's probably OK, since such functions would generally now
> take a bitmap_git argument and use that (e.g., rebuild_existing_bitmaps
> works that way after your patch).

Yes, and I've checked that the existing callers do not use bitmaps twice. I've appended an extra paragraph for the commit message to this e-mail below that will hopefully clarify things.

> We probably need to free(bitmap_git) before returning NULL here (this is
> still in prepare_bitmap_git()).
[snip]
> Ditto here (and probably other error returns lower in the function, but
> I didn't go through it carefully).

The contents of the struct also need to be handled, and I wanted to handle it all at once in the subsequent patch. But you're right that the commit message should explain that.

Here's an paragraph to be added to the end of the commit message. I can send a reroll with the exact same code but with the updated commit message if Junio requests it.

[additional paragraph begin]

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.

[additional paragraph end]
Previous: Jeff KingNext: Jeff King
Message 6 of 9 in “Object store refactoring: make bitmap_git not global”
  1. 0/2 Object store refactoring: make bitmap_git not globalJonathan Tan, Jun 7, 2018
  2. 2/2 pack-bitmap: add free functionJonathan Tan, Jun 7, 2018
  3. Jeff KingJun 9, 2018
  4. 1/2 pack-bitmap: remove bitmap_git global variableJonathan Tan, Jun 7, 2018
  5. Jeff KingJun 9, 2018
  6. Jonathan TanJun 11, 2018
  7. Jeff KingJun 11, 2018
  8. Stefan BellerJun 12, 2018
  9. Brandon WilliamsJun 25, 2018

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.