Parallel compilation support?

I've realized that while building racket, a lot of the action happens on a single core.

Invoking make -j16 at the top level, I see two things:

  • zuo apparently running things sequentially (please correct me if I'm wrong)
  • some nested libraries are being built sequentially, even though they are using make
:: make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
:: make[1]: Entering directory '/root/parts/racket/build/src/cs/c/ChezScheme/ta6le/lz4/lib'

As core counts raise, this makes a lot of the build machine idle. Is there a way to address this easily?

zuo will run multiple jobs in parallel, and it will communicate the jobserver to recursive make calls. You can see a transcript here where -j 18 is automatically communicated to the lower levels, including to raco setup: DrDr / R65264 / pkg-src / build / make

Thanks for responding. I think that either my setup has something special that breaks this or my expectations are off:

I see this process tree:

  β”‚       β”‚       β”‚   └─make -j16
  β”‚       β”‚       β”‚       └─sh -c bin/zuo . all MAKE="make"
  β”‚       β”‚       β”‚           └─zuo . all MAKE=make
  β”‚       β”‚       β”‚               └─racketcs -X /root/parts/racket/build/collects -G /root/parts/racket/build/src/cs/c/compiled/etc -R /root/parts/racket/build/src/cs/c/compiled -N raco -l- setup --no-user --no-launcher --no-foreign-libs --no-install --no-post-install --no-pkg-deps
  β”‚       β”‚       β”‚                   └─36*[{racketcs}]

With the build process producing:

:: raco setup: 7 making: <pkgs>/gui-doc/mrlib/scribblings/hierlist
:: raco setup: 7 making: <pkgs>/gui-lib/mrlib
:: raco setup: 7 making: <pkgs>/gui-lib/mrlib/hierlist
:: raco setup: 7 making: <pkgs>/gui-lib/mrlib/private
:: raco setup: 7 making: <pkgs>/gui-lib/mrlib/private/aligned-pasteboard
:: raco setup: 7 making: <pkgs>/gui-lib/scheme
:: raco setup: 7 making: <pkgs>/gui-lib/scheme/gui
:: raco setup: 7 making: <pkgs>/gui-lib/scheme/gui/lang
:: raco setup: 7 making: <pkgs>/gui-lib/scribble
:: raco setup: 7 making: <pkgs>/gui-lib/scribble/private
:: raco setup: 7 making: <pkgs>/gui-pkg-manager-lib/pkg
:: raco setup: 7 making: <pkgs>/gui-pkg-manager-lib/pkg/gui
:: raco setup: 7 making: <pkgs>/gui-pkg-manager-lib/pkg/gui/private
:: raco setup: 7 making: <pkgs>/htdp-doc/graphics
:: raco setup: 7 making: <pkgs>/htdp-doc/graphics/scribblings

With the build machine being largely idle. Is that expected?

Definitely that process (running raco setup) will be the only one running for a large portion of the time, but it will use multiple cores. However, it looks like the jobserver isn't propagating the -j option to raco setup properly and thus it isn't using 16 cores (7 is the process number so it's at least using 7). What is make on your system, and what version of Racket are you building?

Looking some more, there are multiple stages during the build, this one looks particularly sequential:

  β”‚       β”‚       β”‚               └─scheme -q cs/c/ChezScheme/xc-ta6le/s/cmacros.so cs/c/ChezScheme/xc-ta6le/s/priminfo.so cs/c/ChezScheme/xc-ta6le/s/primvars.so cs/c/ChezScheme/xc-ta6le/s/env.so cs/c/ChezScheme/xc-ta6le/s/setup.so cs/c/ChezScheme/xc-ta6le/s/xpatch

This lights up one core, hinting at internal sequentially.

I'm building racket 8.11.1 with make 4.3 as in Ubuntu 22.04

As in, the "source" build from here: Racket: Racket 8.11.1 ?

I'm using this tarball: https://download.racket-lang.org/releases/8.11.1/installers/racket-8.11.1-src.tgz

Ok, I see this same behavior with the "source" tarball. When I build from the git sources at GitHub - racket/racket: The Racket repository using the top-level make target then I get appropriate parallelism, but if I directly go to racket/src and run configure and then make -j 8 I again get the jobserver warning and no parallelism. So this seems like a bug somewhere in the build system. Probably @mflatt is the right person to look into this.

2 Likes

Thanks for debugging this. I'm sure that with enough eyeballs this can be addressed. When there's a patch, even before the full release, I'd be happy to cherry-pick to make iteration faster.

1 Like

I've just pushed a change to the makefile stub for racket/src, adding the +s that are needed to propagate -j and jobserver pipes for some versions of GNU Make (especially newer ones). That depends on some post-8.11 fixes already in place at the Zuo level.

Those changes don't address the scheme -q cs/c/ChezScheme/xc-ta6le/s/cmacros.so ... step in building Chez Scheme. The zuofile at that level has two targets: one builds files independently so that they can happen in parallel, and one builds in a single scheme process. The latter is mostly used β€” imitating historical behavior, which was probably chosen because compilation is so fast when the compiler itself is compiled to native code. When the compiler is running slowly through pb interpretation in the bootstrap phase, though, separate compile processes would probably make more sense. I haven't yet tried changing that.

1 Like