Repository navigation
fix(compile-cache): bound persistence after termination signals - #36
Merged
Merged
Conversation
steipete
force-pushed
the
codex/compile-cache-exit-budget
branch
2 times, most recently
from
September 30, 2026 07:23
5449145 to
80cc4a6
Compare
steipete
marked this pull request as ready for review
September 30, 2026 07:23
steipete
force-pushed
the
codex/compile-cache-exit-budget
branch
from
September 30, 2026 09:11
80cc4a6 to
16560b0
Compare
Keep full persistence for normal exits and explicit flushes. Record native termination signals before JS dispatch, defer background generation until the main loop is idle, and use weak VM wakeups so pending work is not stranded. Publish completed entries atomically without holding the module-fetch lock across disk I/O.
steipete
force-pushed
the
codex/compile-cache-exit-budget
branch
from
September 30, 2026 09:29
16560b0 to
84f039d
Compare
steipete
added a commit
that referenced
this pull request
Oct 1, 2026
…53) On Linux, a tick that consumed pending native wakeups disabled idle accounting but could still park for the full poll timeout, so the idle time deferred compile-cache generation waits for was never counted and persistence starved (#36's 'compile cache wakes an idle loop for deferred modules' hit its watchdog 3/5). Poll without blocking after consuming wakeups so the next tick parks with idle accounting. #36's idle window and signal-exit budget are unchanged; 30/30 isolated runs pass, fault injection still trips the watchdog, cold SIGTERM exit ~264 ms.
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.
Cold
NODE_COMPILE_CACHEpersistence can delay SIGTERM shutdown while Bun recompiles every loaded module. The reported OpenClaw Gateway measurement was 12.6 seconds cold versus 0.44 seconds warm (0.45 seconds with compile caching disabled).Record native SIGTERM/SIGINT/SIGHUP before JavaScript dispatch and cap automatic exit persistence to 250 ms after those signals. Normal exits and explicit
module.flushCompileCache()still fully persist. Signals received while automatic persistence is already waiting activate the same budget, including time already spent.Generate and atomically publish cache entries after a quiet, mostly idle main-loop window. Background notifications are coalesced, the worker runs at reduced priority where available, and new module loads pause its batch. Weak VM wakeups keep deferred work moving without keeping the VM alive. Generation and disk I/O run outside the module-fetch lock. Standalone
--compile --bytecodebehavior is unchanged.Current integration and native validation
Rebased onto
openclaw/main4c1d6f60d5320f08faf24681036ec9e38f4e5f72, including #37's deferred IPC/stdio ports on top of #28. Final head and tested native binary:84f039d39c1eec8043e36328b93ede8bcea46be3. Both PR commits are unchanged by range-diff; the rebase had no conflicts. In the overlapping files, #37 adds IPC channel-reference fields and changes message/disconnect listener accounting. The termination-signal hooks, both idle-poll hooks, and budgeted persistence retain their exact placement and implementation. #37's IPC/stdio changes remain intact.A fresh macOS arm64 release build of this combined result passed. The prior build directory had been removed, so this qualification recreated it using cached toolchain/dependencies. Main already contains the SDK27 signpost fix; no build-only patch or workflow/WebKit build-script change is included.
test/js/bun/spawn/spawn.ipc.test.tstest/js/node/child_process/child_process.test.tsAll runtime suites passed on their first run after this rebuild. IPC/child-process suites used #37's qualification settings:
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING=1 BUN_GARBAGE_COLLECTOR_LEVEL=0,--max-concurrency 2, run sequentially. CI does not build or run these Bun suites; these are local native results.Compile-cache regressions cover normal/full persistence; handled SIGTERM/SIGINT/SIGHUP; SIGUSR1; unhandled self-SIGTERM; a signal arriving during automatic persistence; accepted warm blobs; atomic entry lengths/hashes; frequent-timer idle; and deferred modules after JS timers are removed. The deferred-idle test detects ten seconds without progress while retaining its thirty-second overall limit. Its former throughput deadline failed under shared-host load on both old and rebased binaries despite continued cache publication; signal-to-exit assertions were not relaxed.
Retained F3 application measurements
The #37 rebase did not change a signal or event-loop hook site, so Gateway measurements were not rerun for this delta. The following measurements are from the immediately preceding F3 qualification, not the new
4c1dbuild.Fresh detached OpenClaw
origin/mainat20245922ee0d860065d2cb5d513e38950660b619,pnpm installand fullpnpm build. Isolated HOME/state/config/cache, loopback ports, and no Node executable on the application PATH. SIGTERM sent immediately after Gateway listening. CLI warm is the second run with the same cache. The source-checkout launcher used its existingOPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED=1marker to retain native compile caching.Unpatched F3 release:
82b5d98968ecfc704192b42baa610518b8959a57from #35, with the exact same Git tree as merged F3 maine6e11d6837699576857dccc02cdd9d046e5665c5. Candidate native build:0d8659067e6444cb8df53310a2ca2442e179da41. All own builds/checks finished before measurements. The shared macOS host had substantial timing spread.Three interleaved rounds per cell; median (min–max), seconds. All samples retained.
The short cold-version result was checked with five additional interleaved pairs: median wall time 91.3 ms unpatched versus 90.3 ms candidate (ranges 58.6–270.8 / 57.1–291.4 ms); warm 36.1 versus 35.2 ms (29.4–59.5 / 28.8–71.2 ms). All samples are retained. The requested warm CLI results showed no measured regression. The 250 ms budget covers compile-cache waiting; the table measures complete Gateway shutdown, including cleanup and scheduling delay. That cohort's integrity audit found 40,312 valid published entries and no partial/corrupt entries.
Earlier five-round pre-F3 qualification verified idle population: 6,219 of 6,221 entries were written before SIGTERM, with a 140 ms median shutdown after idle. Normal-exit TypeScript warm runs were 29.7 ms candidate versus 30.0 ms baseline. These remain historical design checks.
The previous F3 qualification passed all 12 Rust cross-target checks. Current-head Rust/type/lint checks are additionally tracked in this PR's fork CI; they do not replace the native runtime tests above.
Please hold for fork-owner review. This PR remains unmerged; no upstream PR has been submitted.