Repository navigation
Build the libraries in parallel stages - #868
Dummgelaufen007 wants to merge 3 commits into
Conversation
|
Interesting, is it possible to get some kind of reliable benchmark how much build time i saved by this? the CI build times are a bit all over the place, but judging by "best times" it seems to be around 2min saved? |
|
Most of the spread comes from the runners, not from the builds.
The arm64 "best times" all come from Compared on the same machine type,
On arm64 this PR takes as long on a There is only one run of this PR so far; a re-run that lands on an Runs used (job time from start to completion):
Research and wording by Claude (Anthropic), directed and reviewed by me. |
|
Thanks for testing, have not forgot about this and, still debating with myself if the gain is worth the complexity. I wonder how this will behave with build machines with different resources, ex how aggressive is docker build with parallelization? could you end up with OOM or cache thrashing? also wonder where the current build ends up waiting or under utilizing the cpu? |
ComplexityThe complexity is not new: a build like this only works if you know the dependencies, serial or not. The serial Dockerfile keeps them implicit, in the order of the recipes and in one long package list, so each one has to be rediscovered by trial, as for #856 when dav1d had to move above librsvg. With stages, It might also be a small step towards what #216 was after: each library keeps its parts together in one stage, and its dependencies are written down, like pango with Machines with different resourcesA plain Each library takes a little longer that way, but the whole build is done much sooner, since one library's single-core steps no longer leave the other cores idle. What grows is memory, since every library being built needs its own. On four of my machines, a plain
The more cores, the more idle time there is to fill; with two cores there is little, but the build does not get slower either. On your CI runners with 30 or more cores it takes half the time on amd64 and a third on arm64. OOM and cache thrashingOn GitHub's default runners, 4 threads and 16 GB, it builds without any limit on both amd64 and arm64 (run). It needs about 2 GiB of RAM per thread; in a test VM with 1 GiB per thread it ran short, with 2 GiB it went through. The crowding costs each library time, x265 took three to four times as long as in the serial build, yet the build as a whole was still done first. Should the crowding ever be a concern, Where the current build waitsAbout a third of the serial build is spent in steps that use one core: downloading, unpacking,
On the faster Runs used
Research and wording by Claude (Anthropic), directed and reviewed by me. |
Answers the maintainer's questions on wader#868 in his order: complexity, machines with different resources, OOM and thrashing, and where the serial build waits, based on builds without limit on four of my hosts, the CI runs and two colima runs with 4 and 8 GiB of RAM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # Dockerfile
Build the libraries in parallel stages
Almost none of the libraries needs another self-built library, yet each one waits for all the ones before it. The goal of this PR is a shorter build: libraries that do not depend on each other are built at the same time, so the runner's cores do work while one library is in a phase that uses only one of them.
Only where a library uses another self-built one, its stage builds on the stage of that library:
-DCONFIG_TUNE_VMAF=1, librsvg needs dav1d for avif, libdvdread links libdvdcss when it is enabled.cairo-gobject(meson.build#L71), which cairo builds only when it finds glib (meson.build#L587-L598). Today the order of the recipes meets this without saying so.harfbuzz also stays on glib, which it uses when it finds it (meson_options.txt#L2), so it is built as today.
rust, cargo and cargo-c move from the package list of
baseinto their ownruststage. Every chain starts atbase, and only librsvg and rav1e need rust, so the others no longer wait for its install.versions.json
The library versions are
ARGs of their own stages now, sobuilderno longer sees them asenv.X_VERSION. Instead each library that has a key inversions.jsonends itsRUNwith one line that writes its version to a file named after that key, e.g.echo "$VMAF_VERSION" > /usr/local/share/versions/libvmafThe
COPY --fromlines bring these files intobuilderwith the rest of/usr/local. Theversions.jsonstep keeps reading the apk packages and ffmpeg as before and adds one entry per file, with the file name as key:jq -S -Rn '{ ... } + reduce inputs as $v ({}; . + {(input_filename | split("/")[-1]): $v})' /usr/local/share/versions/* > /versions.jsonlibfdk-aac and libdvdcss write their file only when
ENABLE_FDKAACorENABLE_LIBDVDCSSis set, which replaces the twodel(). The keys are the same as today;-Ssorts them.ffmpeg itself stays the same: the same libraries, built with the same recipes.
Research and wording by Claude (Anthropic), directed and reviewed by me.