Skip to content

fix(compile-cache): resume deferred persistence after native wakeups - #53

Merged
steipete merged 1 commit into
mainfrom
claude/compile-cache-idle-persistence-w47
Oct 1, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/compile-cache-idle-persistence-w47

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown

Linux can strand deferred compile-cache work after an application removes its last JavaScript timer. The existing regression hit its idle persistence stalled watchdog in three of five isolated runs on fork main 17c9ecf9eb, under the CI GC/integrity settings.

A native wake delivered during one poll leaves pending_wakeups set for the following tick. That counter disables idle accounting, but Linux still passed the blocking timeout to epoll after the wake event had already been dispatched. Periodic compile-cache wakeups therefore kept reaching the main loop while its one-second observation windows recorded zero idle time. Temporary diagnostics confirmed exactly that sequence. macOS already polls immediately in this state.

Normalize the pending-wakeup poll to a zero timeout before deciding whether to hand off the allocator or measure idle. This lets the subsequent real wait count toward deferred generation. The one-second/90% idle policy, weak VM lifetime, 250 ms signal-exit budget, and regression test deadlines are unchanged. No diagnostics or fault injection are included. Documentation and the fork changelog describe the restored behavior.

Validation

Direct AWS Linux x64, same host and toolchain for baseline and candidate. Native release builds use --lto=off. Isolated runs use BUN_GARBAGE_COLLECTOR_LEVEL=1, BUN_JSC_randomIntegrityAuditRate=1.0, the internal-testing flag, and disabled runtime transpiler cache.

Check Result
Unchanged baseline deferred-idle regression 2 pass / 3 watchdog failures in 5 isolated runs
Patched deferred-idle regression 30/30 pass, 4.321–4.371 seconds each; no retries or deadline changes
Scratch build disabling the native wakeup 3/3 hit the original deferred-persistence watchdog
Full module, compile-cache, standalone, bytecode, perf-hooks and compile-cache watch suites 207 pass / 0 fail / 3 existing skips / 1 existing todo across 15 files
Ported Node compile-cache scripts 14/14 pass with patched Bun; 14/14 pass with Node 24.21.0
Cold SIGTERM, 2,000 uncached modules 5/5 exit successfully in 263.777–263.887 ms; zero entries before signal; 3,210 published entries pass length and SHA-256 checks
Source lints 185/185 pass
Documentation formatting and diff checks Pass
Independent Codex review through P2 Local and committed-branch reviews both scoped-clean; branch review includes the full event-loop source

The 250 ms budget covers compile-cache waiting; the shutdown measurements include process teardown and observer scheduling. All original normal-exit, explicit-flush and signal tests remain enabled. Unpatched runs with GC stress disabled passed 3/3; stress affects the timing that exposes the accounting defect, rather than indicating a collected VM or a weak-handle lifetime error.

The reviewed native candidate source matches this branch's changed-file blobs; no instrumentation or fault injection remains. The paired OpenClaw consumer checks at 01e328528a48eb8c18abeed66d12992500feacef pass identically before/after: src/infra/node-compile-cache.test.ts 7/7 and src/entry.compile-cache.test.ts 23/23. Both use OPENCLAW_VITEST_RUNTIME=bun, the corresponding binary first on PATH, one worker, private HOME/state, and a private 0700 short temp directory. Native CI run 36889495527 is green on head 3bf1bd1d3e1769f119aac30523f5f88693a81391 (merge ref 23cbe4b474cff656c044db38dc27652dcae5d328). Its downloaded result artifact confirms all 13 selected test files passed, including the full module regression file. Format and JavaScript lint are also green. The separate Claude automation fails at environment validation because its required authentication is missing; it produced no code finding.

Upstream status

No upstream fix was found in searches for compile-cache idle/wakeup failures. The event-loop-utilization work in oven-sh#32618 explains the original accounting infrastructure; this is a fork follow-up to #36 and the flake retained in #49/#51.

Do not merge.

Prevent a pending-wakeup tick from blocking after its kernel event was already dispatched. Linux otherwise excludes the wait from idle accounting and can starve deferred compile-cache generation indefinitely. Match the existing immediate-poll behavior on macOS before allocator and idle decisions.

The unchanged deferred-idle regression fails three of five isolated baseline runs and passes all 30 patched runs with CI GC/integrity settings. Preserve the idle-generation policy and signal-exit budget.
@steipete
steipete merged commit 2825e4d into main Oct 1, 2026
7 of 9 checks passed
@steipete
steipete deleted the claude/compile-cache-idle-persistence-w47 branch October 1, 2026 16:24
steipete added a commit that referenced this pull request Oct 5, 2026
Cold Node compile-cache persistence on Windows can exceed the existing 30-second regression deadlines while the idle loop keeps waking and cache entries keep appearing. The Windows rename helper reopened every temporary file with `FILE_TRAVERSE`, which is [`FILE_EXECUTE` for a regular file](https://learn.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants). Microsoft Defender synchronously scanned these files before granting that unnecessary access.

Use the existing non-executable fallback access mask for the first and only open, removing the redundant retry. Keep synchronization, write, and delete rights, sharing defaults, and atomic rename. The compile-cache workload, test deadlines, one-second/90% idle policy, and 250 ms signal-exit budget are unchanged. The watchdog only gains entry-count and child-exit diagnostics. The CI notes distinguish this Windows timeout from the Linux idle-accounting bug already fixed by #53.

The original Windows binary at `d5ada8e6d0c62a51ead1eaccee40cc8388ad3ede` fails the unchanged idle test in five of five isolated runs. Independent observations show continuous progress and completion around 32 seconds. Interleaved Windows API controls over 2,000 unique files spend 24.532/24.509 seconds reopening with execute access, versus 0.119/0.116 seconds without it. Defender's trace attributes 2,001 `OnOpen` scans to cache temporary files, totaling 23.703 seconds during a 28.093-second flush. Defender remained enabled throughout.

With the fix at `918fe702a958256698b429e6c0f4940b1f5d4aef`, three same-host pairs turn unchanged 30.089/30.085/30.085-second timeout failures into 10.714/10.172/10.250-second passes. The standalone explicit-flush reproduction drops from 29.545 seconds to 3.821 seconds while retaining all 2,001 entries. The full Windows module and filesystem suites pass. The filesystem run uses the repository runner's existing 90-second per-test policy; no configured deadline was changed.

Final head: `d708b0f50d8e4dfde3d56f8ddde6719c1830243a`.

- [Native CI](https://github.com/openclaw/bun/actions/runs/37377495588): Linux 15/15 and Darwin 12/12, including the full module file. The tested merge tree exactly matches the PR head.
- [Windows qualification](https://github.com/openclaw/bun/actions/runs/37377645374): x64 and ARM64 each pass 31/31 compatibility rows, both native smoke tests, and manifest assembly. Frozen workflow `5b3999cd3dbc0ff3d4b32c52865674e6b46bbbd2` builds/tests the exact source above. Its Windows jobs and test policy are unchanged; Linux scheduling uses existing Blacksmith runners, and signing/publication are unreachable. Native smoke verifies the full source revision and engine. Manifest/archive/executable/profile hashes and both PE architectures are independently verified.
- Local macOS: 953 passing module/filesystem/filesystem-promises tests, zero failures. All 12 Rust targets pass without skips.
- Isolated OpenClaw consumer checks: infrastructure compile-cache 7/7 and entry compile-cache 22/22, before and after the exact final binary.
- Format, source/JavaScript lint, Clippy, Miri, and cargo tests pass. P2 landing review with the unchanged temporary-file and compile-cache callers is scoped-clean.

The final native and Windows runtime qualification required no test retries or exceptions. Mordant's explicitly advisory resolver style warning is unchanged from main; no suppression was added.

The same helper exists upstream. The source-only port is open as [oven-sh#44601](oven-sh#44601), with passing Windows x64/ARM64 crate checks and source/Rust/format checks.
steipete added a commit that referenced this pull request Oct 6, 2026
…133)

The test runner can kill an unlimited test’s live child when a completed test’s stale deadline fires. Its process-reaping check treats the no-deadline/EPOCH timestamp as expired. Exclude that sentinel, matching the existing entry timeout check, and cover the completed-deadline/live-child sequence with a deterministic regression.

The deferred compile-cache idle test now preserves its ten-second persistence-progress guard and bounds module loading, pipe flushes, child exit, and cleanup individually. The complete 2,000-module workload, late-module handshake, 2,002-file assertion, idle-generation window, and signal-exit budget remain unchanged.

The exact Windows binary from [run 37386790583](https://github.com/openclaw/bun/actions/runs/37386790583) reproduces the old 30-second aggregate timeout 3/3 under a controlled CPU quota while files keep appearing. An independent driver completes all 2,002 entries in 64.7 seconds; the proposed test passes under that quota in 52.6/52.2 seconds. Deliberately stalled persistence, startup, and exit still fail at their ten-second guards. That hosted failure retained no progress timeline, so its specific runner-level trigger remains unknown. This is distinct from #53’s Linux idle-accounting fix and #130’s Windows execute-access scan fix.

The child-lifetime regression fails 3/3 on old Mac and Windows x64 fork binaries and official upstream Bun `13a98b0d`. Exact-source Windows pairs fail 3/3 before and pass 3/3 with the owner fix. Two stale hook-error column expectations were corrected from 15 to 11 after the pre-change fork reproduced all five failures and Node 24 confirmed column 11; exact source-position and error-attribution checks remain intact.

Final validation applies to `29cbbbf595` on main `10b749212a`:

- P2 Codex autoreview and the final pre-merge review are scoped-clean.
- Local release build passes, with 25 test-runner tests and 214 module tests passing; all 12 Rust targets pass.
- [Native CI](https://github.com/openclaw/bun/actions/runs/37402121441): Linux 16/16 and Darwin 13/13, first attempt. Its merge tree exactly matches the reviewed candidate.
- [Windows CI](https://github.com/openclaw/bun/actions/runs/37402131975): x64 and ARM64 each 31/31, both native smoke jobs and manifest pass on the first attempt. The immutable workflow is separate from runtime source; native revisions, WebKit identity, archive/executable/profile hashes, and PE architectures are verified for this exact source commit.
- OpenClaw consumer tests pass 7 + 22 before and after this exact commit, with the before binary’s tree matching current main and isolated HOME/state/configuration/temp directories.

Format, JavaScript/source lint, Clippy, Miri, and lol-html tests pass. Mordant reports the existing `bare_bool_args` finding in `src/resolver/package_json.rs`; its source, baseline, configuration, toolchain, and explicitly advisory workflow setting are unchanged from main. The initial issue-finder run lacked authentication; no credentials or CI settings were changed.

The shared owner fix is also proposed in oven-sh#44613 with a passing upstream-specific build and full test-runner suite. The separate Windows rename fix remains in oven-sh#44601.
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.

1 participant