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

Re: [PATCH 1/3] Makefile: make the "sparse" target non-.PHONY

From
Jeff King <peff@peff.net>
Date
Sep 22, 2021, 02:24 UTC
Message-ID
<YUqTyJQ8euArYeVn@coredump.intra.peff.net>
In-Reply-To
<patch-1.3-e03fde1b642-20210921T224944Z-avarab@gmail.com>
On Wed, Sep 22, 2021 at 12:55:13AM +0200, Ævar Arnfjörð Bjarmason wrote:
> On my box with -j8 it was fast before, or around 5 seconds, now it
> only takes that long the first time, and the common case is <100ms, or
> however long it takes GNU make to stat the *.sp file and see that all
> the corresponding *.c files are older.

Sort of side note, but I think the main culprit here is all of the $(shell) invocations, etc, we run. Try:

  make SHELL_PATH='sh -x'

to get a taste (do it twice, because the first one will actually rebuild everything due to the changed shell; the second one _should_ be a noop but still runs a bunch of stuff).

Though even that doesn't tell the whole story, as it doesn't make clear which shells are invoked by make directly. Try this:

	cat >/tmp/foo <<-\EOF
	#!/bin/sh
	echo >&2 "==> shell $*"
	exec sh "$@"
	EOF
	make SHELL_PATH=/tmp/foo
There's lots of low-hanging fruit like:

==> shell -c echo TEST_SHELL_PATH=\''/tmp/foo'\' >>GIT-BUILD-OPTIONS+ ==> shell -c echo PERL_PATH=\''/usr/bin/perl'\' >>GIT-BUILD-OPTIONS+ ==> shell -c echo DIFF=\''diff'\' >>GIT-BUILD-OPTIONS+ ==> shell -c echo PYTHON_PATH=\''/usr/bin/python'\' >>GIT-BUILD-OPTIONS+ [...and over a dozen more...]

Those could easily be a single shell invocation, rather than one per echo. Another culprit is GIT-VERSION-GEN, which we run whether it's needed or not, and takes something like 25ms.

It's probably not worth spending too much time micro-optimizing here (and certainly it's orthogonal to your series), but there may be some low-hanging fruit (although a hacky attempt at minimizing the shell calls for GIT-BUILD-OPTIONS didn't seem to show any speedup, so maybe it's not so low-hanging after all).

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 3 of 28 in “Makefile: make "sparse" and "hdr-check" non-.PHONY”
  1. 0/3 Makefile: make "sparse" and "hdr-check" non-.PHONYÆvar Arnfjörð Bjarmason, Sep 21, 2021
  2. 1/3 Makefile: make the "sparse" target non-.PHONYÆvar Arnfjörð Bjarmason, Sep 21, 2021
  3. Jeff KingSep 22, 2021
  4. 2/3 Makefile: do one append in %.hcc ruleÆvar Arnfjörð Bjarmason, Sep 21, 2021
  5. 3/3 Makefile: make the "hdr-check" target non-.PHONYÆvar Arnfjörð Bjarmason, Sep 21, 2021
  6. Jeff KingSep 22, 2021
  7. Ramsay JonesSep 22, 2021
  8. Jeff KingSep 22, 2021
  9. Ramsay JonesSep 22, 2021
  10. Junio C HamanoSep 22, 2021
  11. Ævar Arnfjörð BjarmasonSep 23, 2021
  12. Junio C HamanoSep 23, 2021
  13. Ævar Arnfjörð BjarmasonSep 23, 2021
  14. Junio C HamanoSep 22, 2021
  15. Makefile: make the "sparse" target non-.PHONYÆvar Arnfjörð Bjarmason, Sep 23, 2021
  16. Jeff KingSep 23, 2021
  17. Ævar Arnfjörð BjarmasonSep 23, 2021
  18. Jeff KingSep 23, 2021
  19. Junio C HamanoSep 23, 2021
  20. Ramsay JonesSep 23, 2021
  21. Ævar Arnfjörð BjarmasonSep 24, 2021
  22. Ramsay JonesSep 24, 2021
  23. Ævar Arnfjörð BjarmasonSep 24, 2021
  24. Junio C HamanoSep 24, 2021
  25. Makefile: add a non-.PHONY "sparse-incr" targetÆvar Arnfjörð Bjarmason, Sep 28, 2021
  26. Makefile: add a non-.PHONY "sparse-incr" targetÆvar Arnfjörð Bjarmason, Sep 28, 2021
  27. Junio C HamanoSep 28, 2021
  28. Ævar Arnfjörð BjarmasonSep 28, 2021

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.