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

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



On 2015-07-24 12:19, Jakub Wilk wrote:
> * Jonas Smedegaard <dr@jones.dk>, 2015-07-23, 21:40:
>>> 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?
> 
> dpkg-buildpackage -B will run debian/rules 4 times: once to determine if
> build-arch exist, and once for every target: clean, build(-arch),
> binary-arch.
> 
> dh adds even more debian/rules invocations. It runs it once every target
> (clean, build(-arch), binary-arch), and once for every override.
> 
Indeed - though hardly the common use for override targets, you /can/
exclude a command for free by declaring a /completely/ empty target.

Have a look at:
 $ dh binary --no-act | grep debian/rules | wc -l
 $ dh clean  --no-act | grep debian/rules | wc -l

Which should tell you how many override non-empty targets you have.
Output (of dh <foo> --no-act) is something like:

   dh_testdir
   debian/rules override_dh_auto_configure
   dh_auto_build
   [...]
   dh_installdirs
   debian/rules override_dh_auto_install
   [...]

If your override target is completely empty, the command/target simply
disappears from the list.  Though it does not account for the extra
overhead from dpkg-buildpackage calling build{,-arch,-indep} first in a
separate step.

> So your ":=" variable will be evaluated 4 times, or 7+N times if you use
> dh.
> 
> [...]
> 

It should be doable to reduce the dh side of it to 1+N by caching the
result of make (in a file-based cache).

~Niels


Reply to: