-
Notifications
You must be signed in to change notification settings - Fork 477
Add reanalyze-server with transparent delegation #8127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
- 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 <[email protected]>
777817b to
b68bf16
Compare
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
- 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)
- 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
Move server/IPC/socket-path logic into ReanalyzeServer.ml and keep Reanalyze.ml focused on analysis.
- 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 <[email protected]>
Signed-off-by: Cristiano Calcagno <[email protected]>
- 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
ReactiveAnalysisDemo.mov
Summary
Adds a long-lived reanalyze server that keeps reactive analysis state warm across requests, with transparent delegation:
rescript-tools reanalyze -jsonwill automatically use the server if it’s running.Key features
rescript-tools reanalyzeandrescript-tools reanalyze-serverreanalyze-servertakes no reanalyze args and always runs in editor mode (-json)reanalyze -jsonRESCRIPT_REANALYZE_NO_SERVER=1./.rescript-reanalyze.sock(in the project root)Results (measured by the harness)
deadcode(311 issues)deadcode-benchmark(19K issues)Quick Start: try on your project
1) Build this branch
2) In your project directory
The analyzer reads compiler artifacts (notably
.cmtfiles), so you need to keep your project compiled.rescript build -wnpx rescript build -wThen start the server (keep it running in a separate terminal):
Now in VS Code run “ReScript: Start Code Analyzer”.
The extension invokes
rescript-tools reanalyze -json, which will transparently delegate to the server.3) Stop the server
Press Ctrl+C in the terminal running
reanalyze-server.If the server crashes and leaves the socket behind, remove it:
Technical notes
./.rescript-reanalyze.sockin the project root (avoids macOS UDS path length issues).reanalyze -jsonis delegated; other invocations run standalone.Tests
make test-analysis cd tests/analysis_tests/tests-reanalyze/deadcode make test-reactive-server make test-reactive-server-benchmark