Re: RPi 4 build time

From: Mark Millard via freebsd-arm <freebsd-arm_at_freebsd.org>
Date: Sun, 23 May 2021 01:29:03 UTC
On 2021-May-22, at 18:12, tech-lists <tech-lists at zyxst.net> wrote:

> On Sat, May 22, 2021 at 01:12:23PM -0700, Mark Millard via freebsd-arm wrote:
>> of "cold" cache). Another form of "cold" cache could
>> result from changing compiler options that would change
>> the code generated for (nearly) every file produced so
>> that the cache becomes ineffective.
>> 
>> "hot" refers to having a significant amount of
>> "effective/used cache content" that makes a notable
>> difference in the build times. I'm not that impressed
>> with the terminology but it is was I've seen used the
>> most frequently for ccache. So I used it.
> 
> OK
> 
>> I'm confused how you can know it "provides tremendous
>> speedups" while simultaneously not knowing "when ccache
>> was last used for building anything". 
> 
> what I meant was "I'm not sure of the last time I built
> anything that used ccache" or, more accurately, "I can't remember the
> last time I built anything on that machine" because some building uses
> ccache, others not. But I know that buildworld and friends use ccache.
> 
>> Remember that when comparing to my "from scratch"
>> build times: in my build everything was compiled
>> and linked, no prior build materials around to be
>> reused. So I'm reporting a context where I know
>> how to interpret the result and I'm presenting
>> enough history to establish a repeatable context.
> 
> OK I ran another build. Same sources.
> 
> 1. rm -rf /usr/obj && mkdir /usr/obj
> 2. rm -rf /var/cache/ccache && mkdir /var/cache/ccache
> 
> then:
> 
> make -j10 cleanworld started on Sat May 22 19:10:02 BST 2021
> make -j10 cleanworld completed on Sat May 22 19:10:02 BST 2021
> #
> make -j10 cleandir started on Sat May 22 19:10:02 BST 2021
> make -j10 cleandir completed on Sat May 22 19:10:37 BST 2021
> #
> make -j10 clean started on Sat May 22 19:10:37 BST 2021
> make -j10 clean completed on Sat May 22 19:10:58 BST 2021
> #
> make -j6 buildworld started on Sat May 22 19:10:58 BST 2021
> make -j6 buildworld completed on Sun May 23 00:47:03 BST 2021
> #
> make -j6 buildkernel started on Sun May 23 00:47:03 BST 2021
> make -j6 buildkernel completed on Sun May 23 01:20:31 BST 2021
> 
> so buildworld took 5hr 36min 5s and buildkernel 33min 28s from cold.

So, in your kind of context, if it is sigifnicantly faster than
those figures, you can infer that buildworld and/or buildkernel
was using cache. (Presumes you are not also using META_MODE or
other such. Otherwise there would be multiple possibilities
for sources of avoiding some of the rebuild activity.)

> earlier, I wrote:
> 
>>> make -j6 buildworld started on Sat May 22 15:44:11 BST 2021
>>> make -j6 buildworld completed on Sat May 22 16:20:48 BST 2021
> 
>>> make -j6 buildkernel started on Sat May 22 16:20:48 BST 2021
>>> make -j6 buildkernel completed on Sat May 22 16:49:18 BST 2021
> 
> 36min 37s for make buildworld and 28min 30s for make buildkernel. This
> is what I meant by "tremendous speedups". Other things get built on this
> machine; it has a poudriere instance. So I guess anything using C or C++
> will use the ccache when building. I might not know exactly *when*
> unless I also know (when whatever the machine was compiling), it used
> something that ccache could be used for.

Nice to have examples of both numbers. Thanks.

poudriere has /usr/local/etc/poudriere.conf.sample which
contains material about configuring poudreire for ccache
use:

# ccache support. Supply the path to your ccache cache directory.
# It will be mounted into the jail and be shared among all jails.
# It is recommended that extra ccache configuration be done with
# ccache -o rather than from the environment.
#CCACHE_DIR=/var/cache/ccache

# Static ccache support from host.  This uses the existing
# ccache from the host in the build jail.  This is useful for
# using ccache+memcached which cannot easily be bootstrapped
# otherwise.  The path to the PREFIX where ccache was installed
# must be used here, and ccache must have been built statically.
# Note also that ccache+memcached will require network access
# which is normally disabled.  Separately setting RESTRICT_NETWORKING=no
# may be required for non-localhost memcached servers.
#CCACHE_STATIC_PREFIX=/usr/local

and:

# List of packages that will always be allowed to use MAKE_JOBS
# regardless of ALLOW_MAKE_JOBS. This is useful for allowing ports
# which holdup the rest of the queue to build more quickly.
#ALLOW_MAKE_JOBS_PACKAGES="pkg ccache py*"

and:

# Define to yes to build and stage as a regular user
# Default: yes, unless CCACHE_DIR is set and CCACHE_DIR_NON_ROOT_SAFE is not
# set.  Note that to use ccache with BUILD_AS_NON_ROOT you will need to
# use a non-shared CCACHE_DIR that is only built by PORTBUILD_USER and chowned
# to that user.  Then set CCACHE_DIR_NON_ROOT_SAFE to yes.
#BUILD_AS_NON_ROOT=no

and:

# A list of directories to exclude from leftover and filesystem violation
# mtree checks.  Ccache is used here as an example but is already
# excluded by default.  There is no need to add it here unless a
# special configuration is used where it is a problem.
# Default: none
#LOCAL_MTREE_EXCLUDES="/usr/obj /var/tmp/ccache"

(Not that I've used such.) If I read that right, ccache is
not automatically used just because cache is installed.
Instead /usr/local/etc/poudriere.conf needs to be adjusted.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)