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

Re: Bug#793404: massive waste of CPU time in debian/rules by inline commands



Jonas Smedegaard wrote:
> Quoting Jakub Wilk (2015-07-23 21:08:15)
> > * Eduard Bloch <edi@gmx.de>, 2015-07-23, 19:43:
> >>The problem: I see lots of $(shell ...) stuff. In boost, there are 
> >>about 12 such calls. And they run dpkg-architecture or 
> >>dpkg-parsechangelogs or similar commands. When this was done a just 
> >>couple of times (i.e. before dh(7)), that's acceptable. But now, it 
> >>looks like debian/rules is called many, many times through dh.
> >
> > One mistake boost makes is using ":=" instead of plain "=". Contrary 
> > to popular belief, the former almost always causes more evaluation of 
> > $(shell) stuff, specially when dh is involved.
> 
> Could you elaborate on that?
> 
> I never use short-form dh but would like to understand if the 
> optimizations I've tried to do in CDBS might do more harm than good.

If you use :=, the shell command is immediately run and the result
stored in the variable.  So if you reference the variable a dozen times,
the shell command gets run once.  And if you reference the variable zero
times, the shell command gets run once.

If you use =, the shell command is run when the variable is evaluated.
So if you reference the variable a dozen times, the shell command gets
run a dozen times.  And if you reference the variable zero times, the
shell command gets run zero times.

So := is an optimization if you expect to evaluate the variable more
than once.  It's a pessimization if you don't evaluate the variable.  If
the invocations of make for dh aren't referencing those variables, using
:= is a pessimization.

- Josh Triplett


Reply to: