Re: [yocto] Limiting Yocto Memory Usage
Ulrich Ölmann <[email protected]> Wed, 22 Jul 2026 10:00:41 +0200
| Newsgroups | org.yoctoproject.lists.yocto |
|---|---|
| Message-ID | <[email protected]> |
Hi Randy, On Tue, Jul 21 2026 at 11:22 -0400, Randy MacLeod <randy.macleod@windriver.= com> wrote: > On 2026-07-16 04:22, Ulrich =C3=96lmann via lists.yoctoproject.org wrote: > > > > Hey Luis, > > > > On Fri, Jul 10 2026 at 15:26 -0600, "Luis Merayo via lists.yoctoproject= .org"<[email protected]> wrote: > >> > >> Hi, > >> > >> I would like to know if there is a way to limit Bitbake's Memory usage > >> to a specific percentage of the available RAM. For example, can the > >> Yocto build be limited to use a maximum of 70% of RAM? > > if you are doing your Bitbake work on a machine running a systemd based > > Linux distribution you could simply do something like > > > > $ systemd-run \ > > --user \ > > --scope \ > > --property=3DCPUWeight=3D<YOUR_CPUWEIGHT> \ > > --property=3DIOWeight=3D<YOUR_IOWEIGHT> \ > > --property=3DMemoryHigh=3D<YOUR_MEMORYHIGH> \ > > --property=3DOOMPolicy=3Dkill \ > > --unit=3D"bitbake-run" \ > > bitbake [...] > > > > to somewhat limit the resources, see systemd.resource-control(5) and > > systemd.scope(5) for details regarding the used parameters. > > > > Best regards, > > Ulrich > > > Hi Ulrich, > > Using systemd-run is something that I've been meaning to try so it's good= to > hear that you're doing it. > > Do you have any experiences to share about this approach ? we currently use the systemd-run approach mainly to make resource sharing on our build servers a bit fairer between colleagues when building customer BSPs. One nice side effect is that every single process of the control group gets terminated when the systemd-run scope is terminated. No stray processes are left behind by mistake. > Do you do world builds? So far, I am not using it for world builds. Our use case is more about encapsulating individual build jobs and avoiding that a single build grabs too much of the machine, rather than stress-testing the setup with "bitbake world". > Do you run more than one systemd-run build on a given machine? Yes, in practice we do end up with multiple builds running in parallel on the same machine, since (hopefully ;) all colleagues use the same systemd-run approach. > Of course it doesn't prevent bitbake from pushing the cgroup contained sy= stem > harder that it can handle and bitbake doesn't have any feedback so that's > something > to consider when doing the jobserver or free memory build regulation work. Right. For our purpose, though, it works reasonably well as a pragmatic way to improve sharing/fairness on multi-user build machines. Best regards, Ulrich > ../Randy > > > > > > > >> Could these three variables achieve this? > >> > >> BB_PRESSURE_MAX_CPU, BB_PRESSURE_MAX_IO , BB_PRESSURE_MAX_MEMORY > >> > >> I see the range for these variables is from 1 to 1000000, so I would > >> like to understand if there is a way to specify their values as a > >> function of the available RAM. > >> > >> Regards, > >> > >> Luis > >> > >> > >> This email and any attachments are intended for the sole use of the na= med recipient(s) and contain(s) confidential > >> information that may be proprietary, privileged, or copyrighted under = applicable law. If you are not the intended > >> recipient, do not read, copy, or forward this email message or any att= achments, delete this email message and any > >> attachments immediately. > >> > >> > >> > >> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > >> Links: You receive all messages sent to this group. > >> View/Reply Online (#66645):https://lists.yoctoproject.org/g/yocto/mess= age/66645 > >> Mute This Topic:https://lists.yoctoproject.org/mt/120272854/3616765 > >> Group Owner:[email protected] > >> Unsubscribe:https://lists.yoctoproject.org/g/yocto/unsub [randy.macleo= [email protected]] > >> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > >> > > -- > # Randy MacLeod > # Wind River Linux --=20 Pengutronix e.K. | Ulrich =C3=96lmann = | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |