Replace compiler CPPO specializations with functors - #8542
Merged
Conversation
cristianoc
force-pushed
the
replace-cppo-specializations-with-functors
branch
from
August 10, 2026 09:34
571d407 to
6beded4
Compare
cristianoc
marked this pull request as ready for review
August 10, 2026 09:34
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8542 +/- ##
==========================================
+ Coverage 74.70% 74.83% +0.13%
==========================================
Files 460 477 +17
Lines 62389 63311 +922
==========================================
+ Hits 46608 47380 +772
- Misses 15781 15931 +150
🚀 New features to boost your workflow:
|
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
cknitt
approved these changes
Aug 10, 2026
Replace the compiler's six data-structure CPPO templates and their Dune generation rules with ordinary OCaml functors and small, explicit instantiation modules. Keep Hash_set_poly as a plain polymorphic implementation because its key type is not fixed by a functor argument. Audit every resulting module against production consumers. Remove the unused Hash_set_int specialization and the effectively dead Hash_string specialization, whose only apparent compiler consumer was an always-empty cache for a commented-out function. Remove that cache and its uncalled Ext_ident.reset API; tests instantiate Hash.Make locally where a string-key table is useful. Remove CPPO from the analysis and tools package dependencies. Retain it in the rescript package, with an explanatory comment, because the runtime's explicit regeneration script still invokes the external CPPO executable for its checked-in ReScript specializations. This makes every compiler implementation visible to editors and build tooling, removes generated-source indirection, and uses the language's standard abstraction mechanism while preserving each retained specialization's comparison, equality, hashing, and printing semantics. A four-way OCaml 5.3 release-build experiment compared concrete CPPO and functor implementations, both with and without Flambda. No meaningful compiler-speed difference was observed between CPPO and functors on clean builds of the 150-module runtime corpus, parallel builds, or incremental rebuilds; generated JavaScript was identical. Isolated data-structure benchmarks did show differences without Flambda, but those differences disappeared with Flambda. Flambda itself was slower for representative compilation workloads while improving several sustained parsing and printing benchmarks. Its larger binary and startup cost appear to contribute to the typical-build slowdown, although startup-only measurements do not explain all of it. Investigating Flambda further remains worthwhile, particularly together with a persistent compiler server that can amortize per-file process startup. Add direct coverage for the ordered local-identifier map and retain the existing map, set, hash, hash-set, and vector tests. Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
cristianoc
force-pushed
the
replace-cppo-specializations-with-functors
branch
from
August 10, 2026 14:42
6beded4 to
c9fa8c5
Compare
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-8542 |
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.
Replace the compiler's six data-structure CPPO templates and their Dune generation rules with ordinary OCaml functors and small, explicit instantiation modules. Keep Hash_set_poly as a plain polymorphic implementation because its key type is not fixed by a functor argument.
Audit every resulting module against production consumers. Remove the unused Hash_set_int specialization and the effectively dead Hash_string specialization, whose only apparent compiler consumer was an always-empty cache for a commented-out function. Remove that cache and its uncalled Ext_ident.reset API; tests instantiate Hash.Make locally where a string-key table is useful.
Remove CPPO from the analysis and tools package dependencies. Retain it in the rescript package, with an explanatory comment, because the runtime's explicit regeneration script still invokes the external CPPO executable for its checked-in ReScript specializations.
This makes every compiler implementation visible to editors and build tooling, removes generated-source indirection, and uses the language's standard abstraction mechanism while preserving each retained specialization's comparison, equality, hashing, and printing semantics.
A four-way OCaml 5.3 release-build experiment compared concrete CPPO and functor implementations, both with and without Flambda. No meaningful compiler-speed difference was observed between CPPO and functors on clean builds of the 150-module runtime corpus, parallel builds, or incremental rebuilds; generated JavaScript was identical. Isolated data-structure benchmarks did show differences without Flambda, but those differences disappeared with Flambda.
Flambda itself was slower for representative compilation workloads while improving several sustained parsing and printing benchmarks. Its larger binary and startup cost appear to contribute to the typical-build slowdown, although startup-only measurements do not explain all of it. Investigating Flambda further remains worthwhile, particularly together with a persistent compiler server that can amortize per-file process startup.
Add direct coverage for the ordered local-identifier map and retain the existing map, set, hash, hash-set, and vector tests.
Signed-off-by: Cristiano Calcagno cristianoc@users.noreply.github.com
Stack created with GitHub Stacks CLI • Give Feedback 💬