Skip to content

Make the project—not the module—the compiler’s lifetime boundary - #8675

Closed
fhammerschmidt wants to merge 3 commits into
faster-rewatch-ocaml-signature-cachefrom
faster-rewatch-ocaml-project-session
Closed

fhammerschmidt wants to merge 3 commits into
faster-rewatch-ocaml-signature-cachefrom
faster-rewatch-ocaml-project-session

Conversation

@fhammerschmidt

@fhammerschmidt fhammerschmidt commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Give each OCaml rewatch project a compiler dependency session that survives module jobs and watch edits, including full graph rebuilds. Each job still receives fresh inference, diagnostics, and environment state.
  • Lease decoded small CMI tables and an expanded signature graph to one job at a time. Check load paths and file identity before reuse, verify graph integrity afterward, and restore changed graphs from a saved image.
  • Capture ordinary compiler text output in memory, creating a temporary file only for channel-based or binary output.
  • Add tests for project-session lifetime, reuse across worker batches, mutation recovery, load-path changes, and compiler output behavior.

Measurements

On a synthetic 1,201-module project, the project cache did not show a separate clean-build wall-time gain over the runtime-only cache: nine interleaved pairs measured 839.4 ms versus 843.4 ms. A seven-edit retained-watch gate measured 77 ms in each mode. Moving text capture to memory reduced summed parse-request setup time from 1,211 ms to 11 ms across 1,202 requests; typed CMI checks reduced summed verification time from about 170 ms to 8 ms across 1,201 implementation jobs. See the benchmark README for scope and method.

The available testrepo dependencies came from a Linux container, so the larger testrepo gate was not run on macOS. Its cross-edit performance on larger projects remains unmeasured.

Stack

Depends on #8673.

Validation

  • make checkformat
  • make test
  • make test-rewatch
  • sh rewatch-ocaml/tests/run.sh _build/default/rewatch-ocaml/rescript_ocaml.exe (passed with filesystem event access)

@fhammerschmidt
fhammerschmidt added this pull request to stack #8668 September 25, 2026 18:53
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.80702% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.40%. Comparing base (5d68298) to head (2e2baf5).

Files with missing lines Patch % Lines
compiler/ml/env.ml 70.37% 16 Missing ⚠️
compiler/ext/compiler_request_output.ml 72.72% 15 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           faster-rewatch-ocaml-signature-cache    #8675      +/-   ##
========================================================================
+ Coverage                                 78.27%   78.40%   +0.13%     
========================================================================
  Files                                       481      481              
  Lines                                     65663    65729      +66     
========================================================================
+ Hits                                      51396    51537     +141     
+ Misses                                    14267    14192      -75     
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_driver.ml 75.96% <100.00%> (+0.31%) ⬆️
compiler/ext/compiler_request_output.ml 74.64% <72.72%> (-3.13%) ⬇️
compiler/ml/env.ml 65.80% <70.37%> (+6.64%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fhammerschmidt

Copy link
Copy Markdown
Member Author

Superseded by consolidated PR #8680, which preserves this work as one commit in the combined review branch.

@fhammerschmidt
fhammerschmidt removed this pull request from stack #8668 September 26, 2026 17:55
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