[build-tools] Reset Gradle oom score before launch#3898
Conversation
7352b4f to
0d70011
Compare
66cbf1b to
6664fc5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3898 +/- ##
==========================================
+ Coverage 59.21% 59.25% +0.04%
==========================================
Files 935 935
Lines 41093 41066 -27
Branches 8651 8652 +1
==========================================
Hits 24329 24329
+ Misses 16670 16643 -27
Partials 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0d70011 to
f15ecd7
Compare
6664fc5 to
71bce04
Compare
71bce04 to
fcb02d1
Compare
|
⏩ The changelog entry check has been skipped since the "no changelog" label is present. |
|
Subscribed to pull request
Generated by CodeMention Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Gradle launch wrappers in @expo/build-tools to reset oom_score_adj immediately (at the shell level) before exec’ing ./gradlew, preventing Gradle from inheriting the worker service’s protected OOM score.
Changes:
- Replace the delayed descendant PID scan/override with a pre-launch
/proc/$$/oom_score_adjreset in the Gradle wrapper. - Simplify Gradle execution to a single awaited
spawn(...)and remove the old timeout-based process traversal logic. - Introduce a shared pattern (
getGradleShellCommand) for constructing the Gradle bash wrapper command.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/build-tools/src/steps/utils/android/gradle.ts | Switch step-based Gradle execution to a shell wrapper that resets oom_score_adj before exec ./gradlew. |
| packages/build-tools/src/android/gradle.ts | Apply the same pre-launch OOM score reset approach for the main Android build Gradle runner. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const oomScoreAdjPrefix = | ||
| oomScoreAdj === undefined ? '' : `echo ${oomScoreAdj} > /proc/$$/oom_score_adj || true; `; | ||
| return `${oomScoreAdjPrefix}exec ./gradlew ${gradleCommand} --profile ${verboseFlag}`; |
| const oomScoreAdjPrefix = | ||
| oomScoreAdj === undefined ? '' : `echo ${oomScoreAdj} > /proc/$$/oom_score_adj || true; `; | ||
| return `${oomScoreAdjPrefix}exec ./gradlew ${gradleCommand} --profile ${verboseFlag}`; |
| export function getGradleShellCommand({ | ||
| gradleCommand, | ||
| oomScoreAdj, | ||
| verboseFlag, | ||
| }: { | ||
| gradleCommand: string; | ||
| oomScoreAdj?: number; | ||
| verboseFlag: string; | ||
| }): string { | ||
| const oomScoreAdjPrefix = | ||
| oomScoreAdj === undefined ? '' : `echo ${oomScoreAdj} > /proc/$$/oom_score_adj || true; `; | ||
| return `${oomScoreAdjPrefix}exec ./gradlew ${gradleCommand} --profile ${verboseFlag}`; | ||
| } |
There was a problem hiding this comment.
i know, fixing it in another pull request
Summary
Replace the delayed Gradle descendant
oom_score_adjscan with an immediate shell-level reset before launching Gradle.The worker service is protected with
OOMScoreAdjust=-999, so Gradle inherits that value unless we reset it. This changes the Gradle launch wrapper to write0to/proc/$$/oom_score_adjbeforeexec ./gradlew ..., which makes Gradle and its child processes inherit the default OOM score instead of the worker's protected score.Validation
yarn --cwd packages/build-tools typecheckyarn oxfmt --check packages/build-tools/src/android/gradle.ts packages/build-tools/src/steps/utils/android/gradle.tsyarn oxlint --type-aware --import-plugin --tsconfig ./tsconfig.oxlint.json packages/build-tools/src/android/gradle.ts packages/build-tools/src/steps/utils/android/gradle.ts