Skip to content

Immutable representation of compiled interfaces - #8676

Closed
fhammerschmidt wants to merge 2 commits into
faster-rewatch-ocaml-project-sessionfrom
immutable-compiled-interfaces
Closed

fhammerschmidt wants to merge 2 commits into
faster-rewatch-ocaml-project-sessionfrom
immutable-compiled-interfaces

Conversation

@fhammerschmidt

Copy link
Copy Markdown
Member

Summary

  • Add Frozen_type_graph, an immutable indexed type arena with request-local views that materialize only reached mutable types while preserving graph sharing and cycles.
  • Add Frozen_values, an immutable index for exported values, types, constructors, labels, modules, and module types. When REWATCH_FROZEN_VALUES=1, a project cache shares images across compiler domains and each request owns its materialized declarations.
  • Use lazy opened-name sources in Env to avoid expanding an imported module just to look up selected members. Unsupported shapes retain request-owned fallback paths.
  • Add graph and interface unit tests, compiler-driver coverage, a synthetic fixture generator, a microprobe, and design notes with measurements.

Status and measurements

This is an opt-in experiment; the flag is off by default and the CMI file format is unchanged. On five short synthetic fixtures with four compiler domains, median clean-build time fell from 184.54 to 165.14 ms for abstract types, 170.75 to 165.17 ms for values and records, 192.54 to 162.64 ms for variants, 169.22 to 144.67 ms for modules, and 174.07 to 151.84 ms for opened imports. These measurements are directional and do not establish a production-project speedup.

Selected generated artifacts matched byte for byte in the measured fixtures. Switching the flag can change an internal identifier stamp in a consumer CMI, and therefore its self CRC, even when exported declarations and JavaScript agree; this may cause downstream rebuilds. Larger projects, edit workloads, and fallback frequency still need validation before enabling the flag by default.

Stack

Depends on #8675.

Validation

  • make checkformat
  • make test
  • make test-rewatch

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@fhammerschmidt
fhammerschmidt added this pull request to stack #8668 September 25, 2026 21:24
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.79412% with 438 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.18%. Comparing base (2e2baf5) to head (ff965cc).

Files with missing lines Patch % Lines
compiler/ml/env.ml 34.72% 265 Missing ⚠️
compiler/ml/frozen_values.ml 74.38% 104 Missing ⚠️
tests/ounit_tests/ounit_frozen_values_tests.ml 88.30% 31 Missing ⚠️
compiler/ml/frozen_type_graph.ml 85.43% 22 Missing ⚠️
tests/ounit_tests/ounit_frozen_type_graph_tests.ml 87.87% 16 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           faster-rewatch-ocaml-project-session    #8676      +/-   ##
========================================================================
- Coverage                                 78.40%   78.18%   -0.22%     
========================================================================
  Files                                       481      485       +4     
  Lines                                     65729    66992    +1263     
========================================================================
+ Hits                                      51537    52381     +844     
- Misses                                    14192    14611     +419     
Files with missing lines Coverage Δ
tests/ounit_tests/ounit_tests_main.ml 100.00% <ø> (ø)
tests/ounit_tests/ounit_frozen_type_graph_tests.ml 87.87% <87.87%> (ø)
compiler/ml/frozen_type_graph.ml 85.43% <85.43%> (ø)
tests/ounit_tests/ounit_frozen_values_tests.ml 88.30% <88.30%> (ø)
compiler/ml/frozen_values.ml 74.38% <74.38%> (ø)
compiler/ml/env.ml 57.92% <34.72%> (-7.89%) ⬇️
🚀 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