FreeBSD src
Go to file
Bryan Drewery cf1eeb33be Add a FAST_DEPEND option, off by default, which speeds up the build significantly.
This speeds up buildworld by 16% on my system and buildkernel by 35%.

Rather than calling mkdep(1), which is just a wrapper around 'cc -E',
use the modern -MD -MT -MF flags to gather and generate dependencies during
compilation.  This flag was introduced in GCC "a long time ago", in GCC 3.0,
and is also supported by Clang.  (It appears that ICC also supports this but I
do not have access to test it).  This avoids running the preprocessor *twice*
for every build, in both 'make depend' and 'make all'.  This is especially
noticeable when using ccache since it does not cache preprocessor results from
mkdep(1) / 'cc -E', but still speeds up compilation with the -MD flags.

For 'make depend' a tree-walk is still done to ensure that all DPSRCS
are generated when expected, and that beforedepend/afterdepend and
_EXTRADEPEND are all still respected.  In time this may change but for now
I've been conservative.  The time for a tree-walk with -j combined with
SUBDIR_PARALLEL is not significant.  For example, it takes about 9 seconds
with -j15 to walk all of src/ for 'make depend' now on my system.

A .depend file is still generated with the various rules that apply to
the final target, or custom rules.  Otherwise there are now
per-built-object-file .depend files, such as .depend.filename.o.  These
are included directly by make rather than populating .depend with a loop
and .depend lines, which only added overhead to the now almost-NOP 'make
depend' phase.

Before this I experimented with having mkdep(1) called in parallel per-file.
While this improved the kernel and lib/libc 'make depend' phase, it resulted
in slower build times overall.

The -M flags are removed from CFLAGS when linking since they have no effect.

Enabling this by default, for src or out-of-src, can be done once more testing
has been done, such as a ports exp-run, and with more compilers.

The system I used for testing was:
  WITNESS
  Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_FAST_DEPEND=yes
  DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log.
        The arc was fully populated with src tree files.
  RAM: 76GiB
  CPU: Intel(R) Xeon(R) CPU L5520 @2.27GHz
       2 package(s) x 4 core(s) x 2 SMT threads = hw.ncpu=16

buildworld:
  x buildworld-before
  + buildworld-fastdep
  +-------------------------------------------------------------------------------+
  |+                                                                              |
  |+                                                                              |
  |+                                                                       xx    x|
  |                                                                       |_MA___||
  |A                                                                              |
  +-------------------------------------------------------------------------------+
      N           Min           Max        Median           Avg        Stddev
  x   3       3744.13       3794.31       3752.25     3763.5633     26.935139
  +   3       3153.34       3155.16        3154.2     3154.2333    0.91045776
  Difference at 95.0% confidence
          -609.33 +/- 43.1943
          -16.1902% +/- 1.1477%
          (Student's t, pooled s = 19.0569)

buildkernel:
  x buildkernel-before
  + buildkernel-fastdep
  +-------------------------------------------------------------------------------+
  |+                                                                            x |
  |++                                                                           xx|
  |                                                                             A||
  |A|                                                                             |
  +-------------------------------------------------------------------------------+
      N           Min           Max        Median           Avg        Stddev
  x   3        571.57        573.94        571.79     572.43333     1.3094401
  +   3        369.12        370.57         369.3     369.66333    0.79033748
  Difference at 95.0% confidence
          -202.77 +/- 2.45131
          -35.4225% +/- 0.428227%
          (Student's t, pooled s = 1.0815)

Sponsored by:	EMC / Isilon Storage Division
MFC after:	3 weeks
Relnotes:	yes
2015-11-06 04:45:29 +00:00
bin sh: Avoid copying argv for simple commands. 2015-11-01 22:07:40 +00:00
cddl Remove unneeded _RECURSING_PROGS check. 2015-10-30 21:23:14 +00:00
contrib Fix typo in the function name 2015-11-05 07:43:15 +00:00
crypto Merge OpenSSL 1.0.2d. 2015-10-30 20:51:33 +00:00
etc Restrict 520.pfdenied to only list rules that blocked traffic. 2015-11-05 17:37:14 +00:00
gnu Include "system.h" for isdir() prototype. 2015-11-04 05:38:08 +00:00
include Rename __sentinel to __null_sentinel 2015-11-05 14:55:58 +00:00
kerberos5 Partially revert r288266: Remove SUBDIR_PARALLEL from kerberos5/lib. 2015-10-13 18:52:56 +00:00
lib Revert r290298. Per discussion on tech-userlevel@netbsd.org this change 2015-11-05 17:00:38 +00:00
libexec Rather than using the #define for path names, indirect through a char * 2015-10-31 04:39:55 +00:00
release Deprecate MD5 checksum generation in favor of SHA512. 2015-10-14 22:33:11 +00:00
rescue Make iscsictl and iscsid build if MK_ISCSI == yes 2015-10-17 21:11:42 +00:00
sbin Implement ipfw internal olist command to list named objects. 2015-11-03 10:21:53 +00:00
secure Merge OpenSSL 1.0.2d. 2015-10-30 20:51:33 +00:00
share Add a FAST_DEPEND option, off by default, which speeds up the build significantly. 2015-11-06 04:45:29 +00:00
sys Add a FAST_DEPEND option, off by default, which speeds up the build significantly. 2015-11-06 04:45:29 +00:00
targets Connect mpsutil for META MODE. 2015-10-28 16:22:00 +00:00
tests Add tests for the copyin(9) handling of illegal buffers. 2015-10-19 20:22:17 +00:00
tools Add a FAST_DEPEND option, off by default, which speeds up the build significantly. 2015-11-06 04:45:29 +00:00
usr.bin Add SUBDIR_PARALLEL. 2015-11-06 00:06:10 +00:00
usr.sbin Note if relaxed ordering or no snoop is enabled for each PCI-express device. 2015-11-05 20:24:56 +00:00
.arcconfig Add repository.callsign, to help arcanist figure out what repo it's 2015-07-02 22:23:52 +00:00
.arclint
COPYRIGHT
LOCKS
MAINTAINERS Update MAINTAINERS file to reflect re (gjb) wants to review changes 2015-11-05 23:28:48 +00:00
Makefile Rework the 'make -n -n' feature such that '-n' recurses and '-N' does not. 2015-10-17 16:42:54 +00:00
Makefile.inc1 Allow 'make buildenv' to work anywhere in the src tree. 2015-11-05 22:28:31 +00:00
ObsoleteFiles.inc Add _test suffix to multiple tests in lib/libc to conform to the design noted 2015-11-02 01:29:01 +00:00
README
UPDATING Merge OpenSSL 1.0.2d. 2015-10-30 20:51:33 +00:00

This is the top level of the FreeBSD source directory.  This file
was last revised on:
$FreeBSD$

For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).

The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree.  See build(7)
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.

The `buildkernel` and `installkernel` targets build and install
the kernel and the modules (see below).  Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.

Building a kernel is a somewhat more involved process.  See build(7), config(8),
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information.

Note: If you want to build and install the kernel with the
`buildkernel` and `installkernel` targets, you might need to build
world before.  More information is available in the handbook.

The kernel configuration files reside in the sys/<arch>/conf
sub-directory.  GENERIC is the default configuration used in release builds.
NOTES contains entries and documentation for all possible
devices, not just those commonly used.


Source Roadmap:
---------------

bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

games		Amusements.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

rescue		Build system for statically linked /rescue utilities.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

sys		Kernel sources.

tests		Regression tests which can be run by Kyua.  See tests/README
		for additional information.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.


For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:

  http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html