lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Double-colon rules to prevent remaking makefiles


From: Greg Chicares
Subject: [lmi] Double-colon rules to prevent remaking makefiles
Date: Sat, 18 May 2019 18:50:55 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

TL;DR: Preventing a makefile from being remade, thus:
  Makefile:: ;
is slightly beneficial, but that's probably not important when there's
a real benefit to remaking the makefile. Only actual testing can show
the cost in any particular case; it is more significant for inclusion
of a large number of autodependency files, for example.

Before modifying this line in 'GNUmakefile':
  GNUmakefile $(srcdir)/GNUmakefile:: ;
I wanted to make sure I understood its full significance. Not too long
after that line was committed, it was discussed here:

  https://lists.gnu.org/archive/html/help-make/2006-03/msg00008.html
| >  Makefile : ;
| >  %.mk :: ;
| >
| >  % :: $(OBJDIR) ; :
| >
| > and the question is simply, do either of those last two rules
| > *require* the double colon as opposed to a single colon?  i'm not
| > interested in issues of efficiency, just in absolute requirement.
|
| Just efficiency, not correctness, unless I overlooked something
| in my experiments.
|
| Efficiency has more aspects than just speed. I believe that the
| commands in my makefiles run slowly enough (compiling template-
| heavy C++ code) to overwhelm any overhead that 'make' adds:
| remaking an already-up-to-date system takes only one second.
| The greatest benefit I see in the efficiency of double-colon
| rules here is that it makes 'make -d' output shorter, hence
| easier to read.
|
| Running my build system (based on the multi-arch example) with
| a 'show_flags' target whose rules run quickly, and selectively
| changing double to single colons, I see different savings for
| different double colons. I'm using 'make -d show_flag 2>&1 |wc'
| to measure "efficiency" as number of lines of debug output.
|
| >  Makefile : ;
|
| A double colon in my equivalent of this line saves nine lines
| of debug output. [...the "equivalent" file is 'GNUmakefile'...]
| The biggest savings--almost two thousand lines--comes from
| using a double colon for autodependencies:
|   -include *.d
|   *.d:: ;

This week I repeated that experiment, two ways:
 - with '-d', which I rarely use these days, and
 - without '-d', which is the normal usage,
measuring both
 - amount of '-d' output, which matters little to me now, and
 - run time, which always matters,
for a variety of 'GNUmakefile' targets. Full details follow at the
bottom. The first two targets in the table are
 - trunk after  commit f28084a2a1f6
 - trunk before commit f28084a2a1f6
and the others are never-committed experiments.

  without |  with | wc output with -d | target in makefile
     -d   |   -d  |                   |
   0.751  | 0.750 |  767  6298 54582  | GNUmakefile $(srcdir)/GNUmakefile:: 
source_env_vars ;
   0.747  | 0.741 |  752  6217 53934  | GNUmakefile $(srcdir)/GNUmakefile:: ;
   0.747  | 0.743 |  754  6226 54018  | GNUmakefile $(srcdir)/GNUmakefile: ;
   0.728  | 0.746 |  762  6269 54532  | GNUmakefile $(srcdir)/GNUmakefile:
   0.739  | 0.744 |  762  6269 54532  | GNUmakefile:

Each timing shown is the median of three runs. I can only suppose
that the reason why the first three targets ran faster with '-d' is
random noise. The difference in speed among different ways of writing
the target is slight. The difference in volume of debug output is
slight and unimportant.

This analysis justifies commit f28084a2a1f6: the cost is hardly
noticeable, and easily outweighed by the benefits of commit 210257aee9.

Here's a detailed terminal log:

GNUmakefile $(srcdir)/GNUmakefile:: ;

/opt/lmi/src/lmi[0]$ time make -d show_flags 2>&1 |wc
    752    6217   53934
make -d show_flags 2>&1  0.27s user 0.16s system 58% cpu 0.741 total
wc  0.00s user 0.01s system 1% cpu 0.740 total

/opt/lmi/src/lmi[0]$ time make show_flags >/dev/null 2>&1
make show_flags > /dev/null 2>&1  0.34s user 0.11s system 59% cpu 0.747 total

GNUmakefile $(srcdir)/GNUmakefile: ;

/opt/lmi/src/lmi[0]$ time make -d show_flags 2>&1 |wc
    754    6226   54018
make -d show_flags 2>&1  0.31s user 0.13s system 59% cpu 0.743 total
wc  0.01s user 0.00s system 1% cpu 0.743 total

/opt/lmi/src/lmi[0]$ time make show_flags >/dev/null 2>&1
make show_flags > /dev/null 2>&1  0.34s user 0.11s system 59% cpu 0.747 total

GNUmakefile $(srcdir)/GNUmakefile:

/opt/lmi/src/lmi[0]$ time make -d show_flags 2>&1 |wc
    762    6269   54532
make -d show_flags 2>&1  0.31s user 0.13s system 58% cpu 0.747 total
wc  0.00s user 0.00s system 1% cpu 0.746 total

/opt/lmi/src/lmi[0]$ time make show_flags >/dev/null 2>&1
make show_flags > /dev/null 2>&1  0.31s user 0.12s system 59% cpu 0.728 total

GNUmakefile:

/opt/lmi/src/lmi[0]$ time make -d show_flags 2>&1 |wc
    762    6269   54532
make -d show_flags 2>&1  0.30s user 0.15s system 60% cpu 0.744 total
wc  0.00s user 0.01s system 1% cpu 0.744 total

/opt/lmi/src/lmi[0]$ time make show_flags >/dev/null 2>&1
make show_flags > /dev/null 2>&1  0.28s user 0.15s system 58% cpu 0.739 total

GNUmakefile $(srcdir)/GNUmakefile:: source_env_vars ;

/opt/lmi/src/lmi[0]$ time make -d show_flags 2>&1 |wc
    767    6298   54582
make -d show_flags 2>&1  0.34s user 0.11s system 59% cpu 0.750 total
wc  0.00s user 0.00s system 1% cpu 0.748 total

/opt/lmi/src/lmi[2]$ time make show_flags >/dev/null 2>&1
make show_flags > /dev/null 2>&1  0.33s user 0.12s system 59% cpu 0.751 total



reply via email to

[Prev in Thread] Current Thread [Next in Thread]