Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1608cd4
Experiment: Reactive analysis with skip-lite CMT cache
cristianoc Dec 15, 2025
9d68641
Enable create-sourcedirs by default in rewatch
cristianoc Dec 15, 2025
a137564
Refine reactive_file_collection representation
cristianoc Dec 15, 2025
170a430
Replace C++ marshal_cache with pure OCaml implementation
cristianoc Dec 15, 2025
0237150
Move reactive combinators to dedicated library with composition support
cristianoc Dec 16, 2025
76a7a56
Integrate ReactiveMerge into runAnalysis
cristianoc Dec 16, 2025
24cc15f
Add reactive combinators (lookup, join) and reactive type/exception deps
cristianoc Dec 16, 2025
4264fc2
Fix reactive mode @genType handling and update architecture docs
cristianoc Dec 16, 2025
8df7841
Add store abstractions to eliminate merge overhead in reactive mode
cristianoc Dec 16, 2025
057f8ee
Remove backward solver, use forward fixpoint for liveness
cristianoc Dec 16, 2025
c5fa0c8
Remove refs_to storage, compute lazily only when needed
cristianoc Dec 16, 2025
32d7a34
Implement incremental reactive fixpoint combinator
cristianoc Dec 16, 2025
b44f82a
Fix external refs tracking with explicit join dependency
cristianoc Dec 16, 2025
e6821ea
Fix reactive fixpoint re-derivation on removals
cristianoc Dec 16, 2025
526a68d
DCE: forward-model debug output (no refs_to)
cristianoc Dec 16, 2025
12dafc1
Refactor hasRefBelow to use on-demand per-decl search
cristianoc Dec 16, 2025
822e34f
Update ReactiveSolver TODO with accurate status and missing issues
cristianoc Dec 16, 2025
89e5a6c
Add optional args to reactive pipeline
cristianoc Dec 16, 2025
ae35d8e
Format ReactiveSolver and Reanalyze
cristianoc Dec 16, 2025
43095ab
Make dead_modules reactive in ReactiveSolver
cristianoc Dec 16, 2025
01a92a1
Remove resolvedDead mutation - use reactive liveness check
cristianoc Dec 16, 2025
6521b72
Use per-file issue generation for isInsideReportedValue
cristianoc Dec 16, 2025
1f9a0d0
Make dead_decls_by_file reactive and remove report mutation
cristianoc Dec 16, 2025
17d7715
Make issues_by_file reactive
cristianoc Dec 16, 2025
fd38bf2
Optimize hasRefBelow to use per-file refs
cristianoc Dec 16, 2025
fd26c27
Make incorrect @dead detection reactive
cristianoc Dec 16, 2025
9da28de
Make dead module issues reactive
cristianoc Dec 16, 2025
387cc24
Update reactive pipeline documentation and diagrams
cristianoc Dec 16, 2025
d4bc38a
Add update counters to reactive collections
cristianoc Dec 16, 2025
22436e3
Add stats printing for ReactiveLiveness collections
cristianoc Dec 16, 2025
4f681f4
Add Batch delta type for efficient bulk updates
cristianoc Dec 17, 2025
673559c
Use batch processing for ReactiveFileCollection
cristianoc Dec 17, 2025
96ab0d5
Optimize fixpoint batch handling with single BFS expansion
cristianoc Dec 17, 2025
8155106
Revert "Optimize fixpoint batch handling with single BFS expansion"
cristianoc Dec 17, 2025
fea280e
Reactive: add refined stats tracking, remove V1, rename ReactiveV2 to…
cristianoc Dec 17, 2025
c38a091
Add -mermaid flag and update reactive pipeline diagram
cristianoc Dec 17, 2025
89dc995
Update ARCHITECTURE.md to reflect current reactive system
cristianoc Dec 17, 2025
a80ef88
Simplify reactive pipeline diagram with clearer names
cristianoc Dec 17, 2025
221c900
Add full auto-generated reactive pipeline diagram
cristianoc Dec 17, 2025
384717c
Keep only .mmd source for full diagram (no SVG)
cristianoc Dec 17, 2025
1ac942f
Add edge labels to auto-generated Mermaid diagram
cristianoc Dec 17, 2025
011b5b4
Represent combinators as diamond nodes in Mermaid diagram
cristianoc Dec 17, 2025
8ce11ee
Add colored combinator nodes to Mermaid diagram
cristianoc Dec 17, 2025
fa3d0cf
Fix dead module location and hasRefBelow in reactive mode
cristianoc Dec 17, 2025
8163ad2
Add churn mode for incremental correctness testing
cristianoc Dec 17, 2025
4037f6d
Reanalyze: remove -parallel experiment
cristianoc Dec 28, 2025
cfbff3a
Docs: update reactive reanalyze documentation
cristianoc Dec 28, 2025
e9ce44d
Update README.md
cristianoc Dec 28, 2025
4b63aec
Reanalyze: improve forward-liveness debug logging
cristianoc Dec 28, 2025
2fb4f42
Update package.json
cristianoc Dec 28, 2025
efe1315
Reactive: add per-wave timing debug and top-time summary
cristianoc Dec 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@

- Add support for Set, Map, WeakSet and WeakMap to `@unboxed`. https://github.com/rescript-lang/rescript/pull/8009

- Reanalyze: add reactive incremental analysis (`-reactive`, `-runs`, `-churn`) and Mermaid pipeline dumping (`-mermaid`). https://github.com/rescript-lang/rescript/pull/8092

#### :bug: Bug fix

#### :memo: Documentation

#### :nail_care: Polish

- Rewatch: enable `--create-sourcedirs` by default (now deprecated when explicitly used). https://github.com/rescript-lang/rescript/pull/8092

#### :house: Internal

# 12.0.2

#### :rocket: New Feature

- Reanalyze: add parallel processing for CMT file analysis with new `-parallel` and `-timing` flags, plus benchmark infrastructure for performance testing. https://github.com/rescript-lang/rescript/pull/8089

#### :bug: Bug fix

- Reanalyze: make optional args analysis liveness-aware, preventing false positives when functions are only called from dead code. https://github.com/rescript-lang/rescript/pull/8082
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ test-analysis: lib ninja
test-reanalyze: lib ninja
make -C tests/analysis_tests/tests-reanalyze/deadcode test

test-reanalyze-parallel: lib ninja
make -C tests/analysis_tests/tests-reanalyze/deadcode test-parallel

# Benchmark parallel analysis on larger codebase (COPIES=N for more files)
# Benchmark reanalyze on larger codebase (COPIES=N for more files)
benchmark-reanalyze: lib ninja
make -C tests/analysis_tests/tests-reanalyze/deadcode-benchmark benchmark COPIES=$(or $(COPIES),50)

Expand Down Expand Up @@ -254,4 +251,4 @@ dev-container:

.DEFAULT_GOAL := build

.PHONY: yarn-install build ninja rewatch compiler lib artifacts bench test test-analysis test-reanalyze test-reanalyze-parallel benchmark-reanalyze test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground-cmijs playground-release format checkformat clean-ninja clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean dev-container
.PHONY: yarn-install build ninja rewatch compiler lib artifacts bench test test-analysis test-reanalyze benchmark-reanalyze test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground-cmijs playground-release format checkformat clean-ninja clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean dev-container
2 changes: 1 addition & 1 deletion analysis/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(dirs bin src reanalyze vendor)
(dirs bin src reactive reanalyze vendor)

(env
(dev
Expand Down
15 changes: 15 additions & 0 deletions analysis/reactive/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: build test clean

# Build the reactive library
build:
dune build src/

# Run all tests
test:
dune build test/ReactiveTest.exe
dune exec test/ReactiveTest.exe

# Clean build artifacts
clean:
dune clean

109 changes: 109 additions & 0 deletions analysis/reactive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Reactive Collections Library

A library for incremental computation using reactive collections with delta-based updates.

## Overview

This library provides composable reactive collections that automatically propagate changes through a computation graph. When source data changes, only the affected parts of derived collections are recomputed.

### Key Features

- **Delta-based updates**: Changes propagate as `Set`, `Remove`, or `Batch` deltas
- **Glitch-free semantics**: Topological scheduling ensures consistent updates
- **Composable combinators**: `flatMap`, `join`, `union`, `fixpoint`
- **Incremental fixpoint**: Efficient transitive closure with support for additions and removals

## Usage

```ocaml
open Reactive

(* Create a source collection *)
let (files, emit) = source ~name:"files" ()

(* Derive collections with combinators *)
let decls = flatMap ~name:"decls" files
~f:(fun _path data -> data.declarations)
()

let refs = flatMap ~name:"refs" files
~f:(fun _path data -> data.references)
~merge:PosSet.union
()

(* Join collections *)
let resolved = join ~name:"resolved" refs decls
~key_of:(fun pos _ref -> pos)
~f:(fun pos ref decl_opt -> ...)
()

(* Compute transitive closure *)
let reachable = fixpoint ~name:"reachable"
~init:roots
~edges:graph
()

(* Emit changes *)
emit (Set ("file.res", file_data))
emit (Batch [set "a.res" data_a; set "b.res" data_b])
```

## Combinators

| Combinator | Description |
|------------|-------------|
| `source` | Create a mutable source collection |
| `flatMap` | Transform and flatten entries, with optional merge |
| `join` | Look up keys from left collection in right collection |
| `union` | Combine two collections, with optional merge for conflicts |
| `fixpoint` | Compute transitive closure incrementally |

## Building & Testing

```bash
# Build the library
make build

# Run all tests
make test

# Clean build artifacts
make clean
```

## Test Structure

Tests are organized by theme:

| File | Description |
|------|-------------|
| `FlatMapTest.ml` | FlatMap combinator tests |
| `JoinTest.ml` | Join combinator tests |
| `UnionTest.ml` | Union combinator tests |
| `FixpointBasicTest.ml` | Basic fixpoint graph traversal |
| `FixpointIncrementalTest.ml` | Incremental fixpoint updates |
| `BatchTest.ml` | Batch processing tests |
| `IntegrationTest.ml` | End-to-end file processing |
| `GlitchFreeTest.ml` | Glitch-free scheduler tests |

## Glitch-Free Semantics

The scheduler ensures that derived collections never see inconsistent intermediate states:

1. **Topological levels**: Each node has a level based on its dependencies
2. **Accumulate phase**: All deltas at a level are collected before processing
3. **Propagate phase**: Nodes process accumulated deltas in level order

This prevents issues like:
- Anti-joins seeing partial data (e.g., refs without matching decls)
- Multi-level unions causing spurious additions/removals

## Usage in Reanalyze

This library powers the reactive dead code analysis in reanalyze:

- `ReactiveFileCollection`: Manages CMT file processing
- `ReactiveMerge`: Merges per-file data into global collections
- `ReactiveLiveness`: Computes live declarations via fixpoint
- `ReactiveSolver`: Generates dead code issues reactively

1 change: 1 addition & 0 deletions analysis/reactive/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(dirs src test)
Loading
Loading