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

Re: [RFC PATCH] midx.c: clean up .rev file

From
Taylor Blau <me@ttaylorr.com>
Date
Jun 22, 2022, 21:31 UTC
Message-ID
<YrOKHIjXCb5YgIOr@nand.local>
In-Reply-To
<xmqqtu8c31xp.fsf@gitster.g>
On Wed, Jun 22, 2022 at 12:58:42PM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> Taylor Blau <me@ttaylorr.com> writes:
>
> >   - the MIDX file itself is written using a lock_file, so it is
> >     atomically moved into place, and the temporary file is either
> >     removed, or cleaned up automatically with a sigchain handler on
> >     process death
>
> Good.
>
> >   - the bitmap (written in bitmap_writer_finish(), which is the path for
> >     both single- and multi-pack bitmaps) is written to a temporary file
> >     and moved into place after the bitmaps are written.
> >
> >     ...but this temporary file isn't automatically cleaned up, so it
> >     could stick around after process death. Luckily the race window here
> >     is pretty small, since all of the bitmaps have been computed already
> >     and are held in memory.
> >
> >     This is probably worth a cleanup on its own, too.
>
> As long as the "temporary file" is clearly a temporary file that
> "gc" can recognize and get rid of, it would be OK, I would think.

Yeah, I think either is fine (though it would be slightly nicer to have the sigchain code clean it up ahead of time when possible). In the meantime, nothing is broken, though.

Show 8 quoted lines
> >   - unless GIT_TEST_MIDX_WRITE_REV=1 is in your environment, we won't
> >     *write* a .rev file, hence this is pretty rare to deal with in
> >     practice.
>
> OK, but if we were to write one, we should do the same "write into a
> temporary, rename it in place" dance, right?  Or is a separate .rev
> file is pretty much a thing of last decade that we do not have to
> worry too much about?

Right. Technically we link() it into place, cf. our discussion about it here:

    https://lore.kernel.org/git/xmqq5yqeghck.fsf@gitster.g/

But in general this is not really at all considered common anymore, since we expect all new writes to have the reverse index embedded in the MIDX itself.

Thanks, Taylor

Previous: Junio C HamanoNext: Xiaowen Xia
Message 6 of 9 in “midx.c: clean up .rev file”
  1. midx.c: clean up .rev filehaoyurenzhuxia@gmail.com, Jun 22, 2022
  2. Ævar Arnfjörð BjarmasonJun 22, 2022
  3. Junio C HamanoJun 22, 2022
  4. Taylor BlauJun 22, 2022
  5. Junio C HamanoJun 22, 2022
  6. Taylor BlauJun 22, 2022
  7. Xiaowen XiaJun 27, 2022
  8. Teng LongJun 23, 2022
  9. Xiaowen XiaJun 27, 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.