Skip to content

skc: use execvp for clang to avoid memory overlap#1115

Open
mbouaziz wants to merge 1 commit intomainfrom
skc_memory_issue
Open

skc: use execvp for clang to avoid memory overlap#1115
mbouaziz wants to merge 1 commit intomainfrom
skc_memory_issue

Conversation

@mbouaziz
Copy link
Contributor

@mbouaziz mbouaziz commented Feb 23, 2026

Summary

  • When skc compiles skc with -O2, it peaks at ~4.3GB because it holds ~3.4GB RSS while spawning clang -cc1 which adds ~0.9GB. This causes OOM kills on 4GB CI (CircleCI medium).
  • Instead of running clang as a subprocess, defer the link command: store it in the /backendSink/ SKStore directory, then execvp into clang after runWithGc completes. This replaces the skc process with clang, eliminating the memory overlap.
  • Peak memory drops from ~4.3GB to max(3.4GB, 0.9GB) = 3.4GB.
  • WASM linking path is unchanged (it chains multiple tools sequentially).

Fixes #1114

Test plan

  • Compiler builds successfully (skargo build in skiplang/compiler)
  • Compiler tests pass
  • Build a binary (e.g. skjs) with skargo build --release and verify it works
  • Monitor memory during release build to confirm peak reduction

🤖 Generated with Claude Code

Instead of spawning clang as a subprocess (where both skc ~3.4GB and
clang ~0.9GB coexist in memory), use Posix.execvp() to replace the skc
process with clang after all compilation work is done.

This uses runWithResult instead of runWithGc to propagate the link
command out of the SKStore context. The link command is passed from
the backend mapper via the backendSink directory writer, then returned
through compile() to main(), which calls execvp after SKStore cleanup.

Peak memory drops from ~4.3GB to max(3.4GB, 0.9GB) = 3.4GB, fixing
OOM on 4GB CI environments.

Fixes #1114

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skc: high memory usage during clang invocation causes OOM on 4GB CI

1 participant