Re: [PATCH 0/8] Makefile: make command-list.h 2-5x as fast with -jN
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-10-21 01:11:28
On Wed, Oct 20 2021, Jeff King wrote:
On Thu, Oct 21, 2021 at 01:14:37AM +0200, Ævar Arnfjörð Bjarmason wrote:quoted
Jeff: Just in terms of error prone both of these implementations will accept bad input that's being caught in 8/8 of this series. We accept a lot of bad input now, ending up with some combinations of bad output or compile errors if you screw with the input *.txt files. I think I've addressed all of those in this series.I don't mind more error-checking, though TBH I don't find a huge value in it. But what I did mean was:quoted
If you mean the general concept of making a "foo.gen" from a "foo.txt" as an intermediate with make as a way to get to "many-foo.h" I don't really see how it's error prone conceptually. You get error checking each step of the way, and it encourages logic that's simpler each step of the way.Yes. It just seems like the Makefile gets more complicated, and sometimes that can lead to subtle dependency issues (e.g., the ".build" dependency in the earlier iteration of the series).
FWIW there wasn't an earlier version of the series, just a POC patch I had as a comment in https://lore.kernel.org/git/87r1gqxqxn.fsf@evledraar.gmail.com/ (local)
And in general I'd much rather debug an awk script than a Makefile.quoted
Per Eric's Sunshine's upthread comments an awk and Perl implementation were both considered before[1].Ah sorry, I thought it was just a perl one that had been the show-stopper. I hadn't noticed the awk one. However, the point of my patch was to use perl if available, and fall back otherwise. Maybe that's too ugly, but it does address the concern with Eric's implementation.
I think carrying two implementations is worse than just having the one slightly slower one.
quoted
I.e. I think if you e.g. touch Documentation/git-a*.txt with this series with/without this awk version the difference in runtime is within the error bars. I.e. making the loop faster isn't necessary. It's better to get to a point where make can save you from doing all/most of the work by checking modification times, rather than making an O(n) loop faster.FWIW, I don't agree with this paragraph at all. Parallelizing or reusing partial results is IMHO inferior to just making things faster.
I agree with you in the general case, but for something that's consumed
by a make dependency graph I find it easier to debug things if
e.g. changing git-add.txt results in a change to git-add.gen, which is
then cat'd together.
IOW if we had a sufficiently fast C compiler I think I'd still prefer
make's existing rules over some equivalent of:
cat *.c | super-fast-cc
Since similar to how the *.sp files depend on the the *.o files now,
declaring the dependency graph allows you to easily add more built
things.
quoted
I'm also interested in (and have WIP patches for) simplifying things more generally in the Makefile. Once we have a file exploded out has just the synopsis line that can be used to replace what's now in Documentation/cmd-list.perl, i.e. those summary blurbs also end up in "man git". There's subtle dependency issues there as well, and just having a one-off solution for the the command-list.h doesn't get us closer to addressing that sibling implementation.So I don't know what "subtle dependency issues" you found here, but this is exactly the kind of complexity it was my goal to avoid.
But how? I don't see how narrowly making the loop in generate-cmdlist.sh
gets us closer to generating the "cmds_txt" in the
Documentation/Makefile.
Whereas after this series we're pretty much there in terms of generating
those files. i.e. try:
cat Documentation/cmds-mainporcelain.txt
All of those synopsis blurbs are extracted, and reverse-attributable to
the corresponding files.
The dependencies there are (arguably) subtly broken because those files
aren't re-made if a "cmd-list.made" is more recent, so if you remove one
of the generated text files the Makefile logic will get stuck because
the graph is incomplete (which can happen e.g. if "make clean" is
interrupted, or you run a "git clean -dxf '*.txt'".
I did the latter and ran into that recently, because I was trying to
ad-hoc fix another more general dependency issue we tend to have, which
is using wildcards on potentially generated files, so if you checkout a
new verison, build, and then checkout an old version (or are adding one
of the files involved) a script like build-docdep.perl will "helpfully"
pick up bad dependencies.
I guess you could argue that those are all problems with the Makefile,
but I think they're ultimately best solved by driving the dependencies
from the Makefile.
I.e. all we need is the one list of built-ins in command-list.txt, pair
that up with the "category" and we can always generated everything down
to the manpages correctly without relying on FS wildcards.