skc: use execvp for clang to avoid memory overlap#1115
Open
Conversation
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>
7be3d01 to
992d942
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
skccompilesskcwith-O2, it peaks at ~4.3GB because it holds ~3.4GB RSS while spawningclang -cc1which adds ~0.9GB. This causes OOM kills on 4GB CI (CircleCI medium)./backendSink/SKStore directory, thenexecvpinto clang afterrunWithGccompletes. This replaces the skc process with clang, eliminating the memory overlap.Fixes #1114
Test plan
skargo buildinskiplang/compiler)skargo build --releaseand verify it works🤖 Generated with Claude Code