LadybirdBrowser / ladybird

Truly independent web browser
https://ladybird.org
BSD 2-Clause "Simplified" License
21.71k stars 961 forks source link

OOM killed while compiling #1500

Closed akkartik closed 1 month ago

akkartik commented 1 month ago

I've been building Ladybird from source on a nightly basis. For the last few nights I've been noticing my build get killed by Linux's OOM killer.

This is on a laptop with 16GB RAM running Manjaro Linux 24. The kernel is Linux 6.6.47-1. At the time when the build was getting repeatably OOM-killed by the kernel, there were 13 tasks remaining, based on the [0/13] progress display. The state of system memory was this:

$ free -m
               total        used        free      shared  buff/cache   available
Mem:           15210        8410        6460         241         892        6800
Swap:              0           0           0

The build succeeded after I shut down my browser. I don't have a lot of tabs open; the system memory looked like this after a successful build:

$ free -m               
               total        used        free      shared  buff/cache   available
Mem:           15210        7195        7294         151        1182        8014
Swap:              0           0           0

Do y'all target any system requirements for building Ladybird? (I didn't immediately see them mentioned on the site or the docs.) Based on this superficial analysis, it seems like Ladybird currently requires a peak of ~8GB RAM during the build. This peak has been creeping up in my experience.

circl-lastname commented 1 month ago

You should reduce the amount of simultaneous compiling processes with the MAKEJOBS environment variable (to something less than how many threads your CPU has), additionally check if any apps are using a lot of memory, and avoid using them during the compilation process. A system reboot will also help to start with a lower memory usage.

There are no system requirements for building ladybird, as the only difference is how long it will take to get done, but you must ensure you have enough RAM relative to the number of CPU threads.

ADKaster commented 1 month ago

If there's only 13 tasks remaining, that's probably link jobs. Installing lld or mold should help with that. Those linkers use significantly less RAM than GNU's BFD linker.

But also yes, MAKEJOBS=1 (or 2, 3, 4..) will reduce the number of parallel jobs. For large C++ projects, I would expect that ~1 GiB of RAM per parallel job is a reasonable assumption.

akkartik commented 1 month ago

Thank you for that info!