-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Problem
When skc compiles a binary with -O2, it peaks at ~4.3GB total memory because it holds ~3.4GB RSS while spawning clang -cc1 -O2 which adds ~0.9GB on top. This causes OOM kills on CI environments with 4GB RAM (e.g. CircleCI medium).
Measured Memory Profile
Captured building the skjs binary (skargo build --release --bin skjs) inside skiplabs/skip:latest:
| Time | Process | RSS |
|---|---|---|
| T+0s | skc starts | ~200MB |
| T+10s | skc (compilation) | ~1.8GB |
| T+15s | skc (peak, pre-clang) | ~3.4GB |
| T+15s | skc spawns clang -cc1 | skc: 3.4GB + clang: ~270MB |
| T+25s | PEAK | skc: 3.4GB + clang: ~940MB = ~4.3GB total |
| T+35s | done | released |
Key observations
skcholds 3.4GB RSS the entire time clang runsclang -cc1grows to ~940MB during LLVM codegen at-O2- The two processes overlap: skc doesn't free memory before clang finishes
Suggested Fix
Since skc's job is done once it writes the .ll file, it could:
exec()into clang — replace the skc process entirely, reducing peak to max(3.4GB, 0.9GB) = 3.4GB- Free compilation state before invoking clang
- Fork/exec clang and exit — let clang run independently
Option 1 would be the most effective.
Reproduction
git clone https://github.com/SkipLabs/skjs
git clone --recurse-submodules https://github.com/SkipLabs/skip
# This reliably OOMs:
docker run -d --name skc-oom-test --memory=4g --memory-swap=4g \
-v "$PWD/skjs:/work/skjs" -v "$PWD/skip:/work/skip" \
-w /work/skjs skiplabs/skip:latest \
skargo build --release
docker inspect skc-oom-test --format '{{.State.OOMKilled}}' # true = OOMCurrent Workaround
skjs CI uses skargo build --release --bin skjs instead of skargo build --release to avoid building the test binary (which causes a second 4GB spike). This brings peak from ~4.3GB to ~3.9GB.
Environment
- Docker image:
skiplabs/skip:latest(skc 0.1.0, LLVM 20) - CI: CircleCI medium executor (4GB RAM)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels