Closed#5
Closed
JonoPrest wants to merge 3 commits into
Closed
Conversation
Adds scripts/dce/run-dce.sh + README to run reanalyze DCE over the compiler's own OCaml source. The vendored rescript-tools reanalyze can't do this: the compiler's OCaml is built by host OCaml 5.3 (cmt magic Caml1999I035), while the vendored ml library only reads the 4.06-era ReScript cmt format, so it dies with Cmi_format.Error. Instead we build the standalone reanalyze against host compiler-libs, using the OCaml-5.3 support from rescript-lang/reanalyze#203 (pinned, not yet merged). It works end-to-end and produces a full report. Raw output is currently dominated by entry-point false positives (dune emits only .cmti for the bsc main, and jsoo isn't built in the default profile), so making it actionable needs root/entry-point fixes — documented in the README along with the lowest-noise starting categories (redundant/unused optional args) and the CI-gating proposal.
…ability blocker Two findings from triaging the DCE output: 1. Roots: a plain `dune build` emits only .cmti for modules with an .mli (incl the bsc main), so reanalyze missed the entry-point bodies and over-reported. Switch the runner to `dune build @check`, which emits impl .cmt for every module. Fixes the Bs_version-class false positives (Dead Value ~2740->2130, Dead Module ~203->146). 2. Blocker: even with roots fixed, reanalyze#203 flags obviously-live core modules as dead (Ast_helper has 510 in-tree refs; Lam_compile, Js_dump, Lam_convert likewise). Per the PR, its 5.3 value-dependency tracking is derived 'just based on the type' in cmt_infos and is incomplete (rescript-lang/reanalyze#202). So cross-reference-based categories aren't trustworthy yet. Documented in the README.
Investigated why obviously-live modules (Ast_helper, Lam_compile, Js_dump) are flagged dead. reanalyze's DCE is location-keyed, and OCaml 5.3 broke that on two fronts: cmt_declaration_dependencies is uid-based and carries few edges, and the dominant typedtree-walk reference source relies on Texp_ident val_loc that no longer matches declaration registration cross-module. Confirmed by experiment (local reanalyze branch): a global uid->decl pre-pass is a necessary foundation but insufficient; resolving references via val_uid alone regresses (2129->2526 dead values) because declarations are still keyed by the old location. The real fix keys both declarations and references by uid - a core refactor, not a patch.
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.
No description provided.