Share exact retained function and class source ranges - #10065
proggeramlug wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (9)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe code generator now pools retained source strings into shared LLVM globals and records byte ranges for nested sources. Function and class registrations use pooled pointers and lengths. Unit, IR, reflection, native, and moving-GC tests validate the behavior. ChangesRetained source pooling
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~45 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant SourcePool
participant StringPool
participant LLVMIR
participant NativeDriver
SourcePool->>StringPool: provide pooled source ranges
StringPool->>LLVMIR: emit shared globals and registrations
NativeDriver->>LLVMIR: inspect shared pointers and registration calls
NativeDriver->>NativeDriver: execute reflection and moving-GC checks
Merge Risk: ⚪ Minimal · up to The retained-source pooling change preserves the tested reflection and registration behavior across supported output modes, with no unresolved merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 6 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Share exact nested function/closure/class/method source byte ranges within each module. This is an independent compiler optimization: no application source, runtime API changes, deletion of reflection data or dependency on the in-flight Bun compression PR.
The pool interns identical texts, uses deterministic longest-parent-first substring matching with the already-locked aho-corasick 1.1.4 contiguous NFA, and emits only parent constants. Each existing source registration keeps its original order, symbol/class identity, byte length and strictness bit. Executables retain the static registration API; dylib/staticlib output retains the copying API; class registration still copies. GEP offsets refer to exact bytes, including UTF-8 and NULs. Below 4 KiB or above 8 MiB of unique pattern bytes the matcher is skipped; a 1,000,000-match budget leaves unmatched sources independent. No new environment switch.
Validation so far
bf7f87e61, frozen compiler and all nine matching archives: six native acceptance arms pass (default/compact × text transport/unsplit native construction/two-unit native construction). Every arm emits two live shared source calls, matches pinned Node's full reflection output with input hidden, and reports 201 copying minors, 42,629 moved objects, 4,000 loop polls. No source/stamp substitution. Compiler build 9m21s; provider/Wasm build 10m29s.bf7f87e61is complete (run 34589238833): compilation, warnings and security pass. Lint fails on the same base public benchmark freshness. The runtime phase reports 3,504 passed, one failed, four ignored; its sole failure is the same basenative_stack.rs:53/:60worker-bound assertion. That fail-fast job did not reach the new codegen unit tests, so the local codegen results above are not presented as Linux CI results. The green scoped-E2E job has no new Rust integration entry point here and is not counted as source-pool native evidence.test_gap_retained_source_pool(shard 3, 11:14:40 UTC). Shards 4 and 6 pass; all 11 printed failure/crash diagnostics in shards 1/2/3/5 exactly match main603b074acrun34565492075, including the WebCrypto 10-second timeout. This compares reported exits and printed output excerpts, not full stdout, and does not relabel the red fan-in green. GC stress matches Node in 588/588 cells: 429 PASS, 159 UNVERIFIED, 0 FAIL; the 159 inert arms are not counted as moving-GC evidence.Readiness / limits
Ready: the candidate native acceptance hold is cleared. All six candidate and six pre-pooling baseline arms pass. The unsplit-native candidate pair was initially refused before launch by the disk guard; after space recovered it actually executed and passed at 11:05 UTC. No failed/unfinished arm is counted as successful. All local build/test jobs have finished.
No full application rebuild has been launched. That remains gated on merged main and its 15 GiB start-space guard. This PR is independently implementable/testable and makes no working-application claim.
The gap fixture is included in the normal gap sweep, and pool/IR tests run in the codegen unit suite. The standalone driver is a manual additional acceptance command:
Use
PERRY_TEST_WASM=1only for a provider graph built with wasm-host; otherwise omit it.--expect-unsharedis the explicit pre-fix baseline control, not the acceptance mode.Size scope
Earlier diagnostic registration-only objects over three real retained-source corpora saved 2,238,856 bytes combined (3,514,976 → 1,276,120), with exact range checks. Those were a separate prototype, synthetic registration identities and LLVM objects—not this production compiler or a full application. No final executable-size saving or working Claude prompt is claimed here.
No version bump: left to the maintainer at merge time.