Helmut Grohne
2024-11-28 10:00:02 UTC
Hi Guillem and other developers,
I am one of those who builds a lot of different packages with different
requirements and found that picking a good parallel=... value in
DEB_BUILD_OPTIONS is hard. Go too low and your build takes very long. Go
too high and you swap until the OOM killer terminates your build. (Usage
of choom recommended in any case.)
Common offenders are rustc and llvm-toolchain, but there are a few more.
These packages already offer some assistance.
llvm-toolchain-19 parses /proc/meminfo and reduces parallelism:
https://sources.debian.org/src/llvm-toolchain-19/1%3A19.1.4-1/debian/rules/#L92
A number of packages use debhelper's --max-parallel:
https://codesearch.debian.net/search?q=--max-parallel%3D%5B%5E1%5D+path%3Adebian%2Frules&literal=0
polymake limits parallelity to 4GB per core:
https://sources.debian.org/src/polymake/4.12-3/debian/rules/?hl=15#L15
Another implementation is in openscad:
https://sources.debian.org/src/openscad/2021.01-8/debian/rules/?hl=33#L33
ns3 turns off parallelism if the RAM is too limited:
https://sources.debian.org/src/ns3/3.42-2/debian/rules/?hl=26#L26
I think this demonstrates that we probably have something between 10 and
50 packages in unstable that would benefit from a generic parallelism
limit based on available RAM. Do others agree that this is a problem
worth solving in a more general way?
For one thing, I propose extending debhelper to provide
--min-ram-per-parallel-core as that seems to be the most common way to
do it. I've proposed
https://salsa.debian.org/debian/debhelper/-/merge_requests/128
to this end.
Unfortunately, a the affeted packages tend to not just be big, but also
so special that they cannot use dh_auto_*. As a result, I also looked at
another layer to support this and found /usr/share/dpkg/buildopts.mk,
which sets DEB_BUILD_OPTION_PARALLEL by parsing DEB_BUILD_OPTIONS. How
about extending this file with a mechanism to reduce parallelity? I am
attaching a possible extension to it to this mail to see what you think.
Guillem, is that something you consider including in dpkg?
Are there other layers that could reasonably be used to implement a more
general form of parallelism limiting based on system RAM? Ideally, we'd
consolidate these implementations into fewer places.
As I am operating build daemons (outside Debian), I note that I have to
limit their cores below what is actually is available to avoid OOM
kills and even that is insufficient in some cases. In adopting such a
mechanism, we could generally raise the core count per buildd and
consider OOM a problem of the package to be fixed by applying a sensible
parallelism limit.
Helmut
I am one of those who builds a lot of different packages with different
requirements and found that picking a good parallel=... value in
DEB_BUILD_OPTIONS is hard. Go too low and your build takes very long. Go
too high and you swap until the OOM killer terminates your build. (Usage
of choom recommended in any case.)
Common offenders are rustc and llvm-toolchain, but there are a few more.
These packages already offer some assistance.
llvm-toolchain-19 parses /proc/meminfo and reduces parallelism:
https://sources.debian.org/src/llvm-toolchain-19/1%3A19.1.4-1/debian/rules/#L92
A number of packages use debhelper's --max-parallel:
https://codesearch.debian.net/search?q=--max-parallel%3D%5B%5E1%5D+path%3Adebian%2Frules&literal=0
polymake limits parallelity to 4GB per core:
https://sources.debian.org/src/polymake/4.12-3/debian/rules/?hl=15#L15
Another implementation is in openscad:
https://sources.debian.org/src/openscad/2021.01-8/debian/rules/?hl=33#L33
ns3 turns off parallelism if the RAM is too limited:
https://sources.debian.org/src/ns3/3.42-2/debian/rules/?hl=26#L26
I think this demonstrates that we probably have something between 10 and
50 packages in unstable that would benefit from a generic parallelism
limit based on available RAM. Do others agree that this is a problem
worth solving in a more general way?
For one thing, I propose extending debhelper to provide
--min-ram-per-parallel-core as that seems to be the most common way to
do it. I've proposed
https://salsa.debian.org/debian/debhelper/-/merge_requests/128
to this end.
Unfortunately, a the affeted packages tend to not just be big, but also
so special that they cannot use dh_auto_*. As a result, I also looked at
another layer to support this and found /usr/share/dpkg/buildopts.mk,
which sets DEB_BUILD_OPTION_PARALLEL by parsing DEB_BUILD_OPTIONS. How
about extending this file with a mechanism to reduce parallelity? I am
attaching a possible extension to it to this mail to see what you think.
Guillem, is that something you consider including in dpkg?
Are there other layers that could reasonably be used to implement a more
general form of parallelism limiting based on system RAM? Ideally, we'd
consolidate these implementations into fewer places.
As I am operating build daemons (outside Debian), I note that I have to
limit their cores below what is actually is available to avoid OOM
kills and even that is insufficient in some cases. In adopting such a
mechanism, we could generally raise the core count per buildd and
consider OOM a problem of the package to be fixed by applying a sensible
parallelism limit.
Helmut