Page MenuHomeFreeBSD

fine granular buildworld time statistic by stages and subdirs
Needs ReviewPublic

Authored by wosch on May 26 2025, 4:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 29, 8:10 AM
Unknown Object (File)
Sat, Jun 28, 5:00 PM
Unknown Object (File)
Thu, Jun 26, 4:12 AM
Unknown Object (File)
Wed, Jun 25, 9:08 AM
Unknown Object (File)
Fri, Jun 20, 3:57 PM
Unknown Object (File)
Thu, Jun 19, 1:45 PM
Unknown Object (File)
Wed, Jun 18, 5:27 AM
Unknown Object (File)
Jun 16 2025, 11:29 PM
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

For the `make buildworld' we log the time spent in each stage (bootstrap tools, building libraries, everything etc), as documented in
https://www.freebsd.org/status/report-2021-07-2021-09/#_current_compilation_time_analysis

It would be great if we have more fine granular statistics based on the subdir targets. It turns out that is pretty easy with a wrapper shell script.

apply this patch and
$ chmod 755 ./tools/build/time-buildworld*

build the world
$ make buildworld > buildworld.log

The generated CSV has ca. 2800 lines
$ ./tools/build/time-buildworld-csv.awk buildworld.log > buildworld.csv

output example:
https://people.freebsd.org/~wosch/build-time/buildworld/buildworld.csv
https://people.freebsd.org/~wosch/build-time/buildworld/buildworld.log.gz

The statistics will be generated as CSV, because this is a very simple format and runs on a base system without ports installed.

The columns are: "real", "user", "sys", "start", "end", "exit", "message", "stage"

real: real time in seconds
user: user time used
sys: system time used
start: start time, number of seconds since the Epoch
end: end time, number of seconds since the Epoch
exit: exit status of command(s)
message: the command(s), e.g. sublib lib/libregex
stage: optional, name of stage, e.g. 4.2.4 MACHINE_ARCH=amd64

The overhead for the wrapper script is around 20 CPU seconds, out of 80000 seconds for a fresh full buildworld.

If you dislike this feature or suspect it is causing trouble you can disable it with the variable TIME_ENV=""

Tested on amd64, i386, arm64 and macOS/arm64 cross compiling for ‘buildworld’, and with ‘packages’, ‘tinderbox’, and 'release'

Notes:

  • Do not sum up values, some targets contain other values (recursive subdirs), e.g.

./tools/build/time-buildworld-csv.awk buildworld.log |grep google | awk -F'\t' '{ print $2 "\t" $7}'
63.52 subdir all lib/googletest/gtest
8.16 subdir all lib/googletest/gtest_main
17.97 subdir all lib/googletest/gmock
5.08 subdir all lib/googletest/gmock_main
94.77 subdir all lib/googletest

in this example the subdir “lib/googletest” runs for 94.77 CPU seconds, which is the sum of the subdirs gtest* and gmock*.

  • some stages are called twice for machine related stuff (amd64 + i386)
  • time is recorded when a stage/subdir is done, not when it started. This can be confusing for parallel builds

PS: is is also doable to collect the timestamps in milliseconds with GNU date from coreutils package (gdate +%s.%3N), see PR: 287080

As an example:
https://people.freebsd.org/~wosch/build-time/buildworld/buildworld-gdate.csv

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped