You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add reanalyze-server with transparent delegation (#8127)
* Add reanalyze-server with transparent delegation
- Implement reanalyze-server subcommand that maintains reactive state
- Add reanalyze-server-request client for IPC via Unix socket
- **Transparent delegation**: Regular 'reanalyze' calls automatically use
the server if running on default socket (/tmp/rescript-reanalyze.sock)
- Works with unmodified VS Code extension - just start the server manually
- Create comprehensive test harness with clean warmup/benchmark phases
- Color-coded logging: [BUILD], [SERVER], [REACTIVE], [STANDALONE], [EDIT]
- Test scenarios: add dead code (+1 issue), make dead code live (-1 issue)
- Results: 2.5x speedup (small project), 10x+ speedup (benchmark)
Usage:
# Start server (once, in background)
rescript-editor-analysis reanalyze-server --cwd /path/to/project -- -config -ci -json
# Now regular reanalyze calls automatically use the server:
rescript-editor-analysis reanalyze -config -ci -json
Signed-Off-By: Cristiano Calcagno <cristiano.calcagno@gmail.com>
* reformat
* Add detailed request stats to reanalyze-server
- Log request number, timing, issues, dead/live counts, files processed/cached
- Pass file_stats through runAnalysis to capture processing statistics
- Use locally created mutable stats record instead of global state
- Stats show files processed (new or modified) vs cached (unchanged)
* reanalyze-server: project-root socket + cleanup
- Default socket lives in project root and is discovered by walking up to rescript.json/bsconfig.json
- Use relative socket name to avoid macOS unix socket path length limits
- Unlink socket on exit and on common termination signals
- Update reanalyze README with VS Code (-json) usage
* Extract reanalyze server into dedicated module
Move server/IPC/socket-path logic into ReanalyzeServer.ml and keep Reanalyze.ml focused on analysis.
* reanalyze: add reactive server under rescript-tools
- reanalyze-server runs editor-mode (-json) with no args
- reanalyze delegates to server only for -json
- update reanalyze tests/harness to use rescript-tools
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
* changelog: mention reanalyze-server
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
* reanalyze-server: compact heap after each request, simplify mem output
- Run Gc.compact() after every request to keep memory stable (~257MB)
- Simplify server output to just show live heap: 'mem: 257.0MB'
- Add opt-out via RESCRIPT_REANALYZE_SERVER_SKIP_COMPACT=1 env var
* Reanalyze: support rewatch monorepos via root .sourcedirs.json cmt_scan
- Extend rewatch to emit version:2 .sourcedirs.json with explicit cmt_scan (build roots + scan dirs) for root-level monorepo builds.
- Update reanalyze (editor invocation: rescript-tools reanalyze -json) to prefer cmt_scan when present, with legacy single-project fallback.
- Ensure deterministic output ordering by sorting .cmt/.cmti entries in the cmt_scan path.
Tests: make test-analysis
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
---------
Signed-off-by: Cristiano Calcagno <cristiano.calcagno@gmail.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@@ -85,7 +85,68 @@ The reactive mode (`-reactive`) caches processed per-file results and efficientl
85
85
2.**Subsequent runs**: Only changed files are re-processed
86
86
3.**Unchanged files**: Return cached `file_data` immediately (no I/O or unmarshalling)
87
87
88
-
This is the foundation for a persistent analysis service that can respond to file changes in milliseconds.
88
+
This is the foundation for the **reanalyze-server** — a persistent analysis service that keeps reactive state warm across requests.
89
+
90
+
## Reanalyze Server
91
+
92
+
A long-lived server process that keeps reactive analysis state warm across multiple requests. This enables fast incremental analysis for editor integration.
93
+
94
+
### Transparent Server Delegation
95
+
96
+
When a server is running on the default socket (`<projectRoot>/.rescript-reanalyze.sock`), the regular `reanalyze` command **automatically delegates** to it. This means:
97
+
98
+
1.**Start the server once** (in the background)
99
+
2.**Use the editor normally** — all `reanalyze` calls go through the server
100
+
3.**Enjoy fast incremental analysis** — typically 10x faster after the first run
101
+
102
+
This works transparently with the VS Code extension's "Start Code Analyzer" command.
103
+
104
+
### Quick Start
105
+
106
+
```bash
107
+
# From anywhere inside your project, start the server:
108
+
rescript-tools reanalyze-server
109
+
110
+
# Now any reanalyze call will automatically use the server:
111
+
rescript-tools reanalyze -json # → delegates to server
0 commit comments