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

Re: [PATCH] setup: avoid unconditional open with write flags

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 6, 2022, 00:10 UTC
Message-ID
<xmqq7cz5pf1w.fsf@gitster.g>
In-Reply-To
<Y453yiYAifv/oV5n@nand.local>
Taylor Blau <me@ttaylorr.com> writes:
Show 6 quoted lines
> So it appears that the old version is ever-so-slightly faster than the
> new one. But it's so noisy, and the regression is so small that it's
> hard to notice it at all.
>
> So I wouldn't strongly oppose the patch based on those numbers, but in
> principle it seems flawed.
Thanks for writing and reviewing.

As long as we were touching the function, I suspect that the logic should become more like

    if (fd #0 is not open)
	open /dev/null read-only and give it to fd #0
    if (fd #1 is not open)
	open /dev/null write-only and give it to fd #1
    if (fd #2 is not open)
	open /dev/null write-only and give it to fd #2
with opening of /dev/null optimized not to happen when not needed.
Previous: Taylor BlauNext: Taylor Blau
Message 6 of 10 in “setup: avoid unconditional open with write flags”
  1. setup: avoid unconditional open with write flagsChristian Göttsche, Dec 5, 2022
  2. brian m. carlsonDec 5, 2022
  3. Jeff KingDec 6, 2022
  4. Christian GöttscheDec 6, 2022
  5. Taylor BlauDec 5, 2022
  6. Junio C HamanoDec 6, 2022
  7. Taylor BlauDec 6, 2022
  8. Junio C HamanoDec 6, 2022
  9. René ScharfeDec 6, 2022
  10. Junio C HamanoDec 6, 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.