-
Notifications
You must be signed in to change notification settings - Fork 476
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".
analysis/reanalyze/src/Reanalyze.ml
Outdated
| with_cwd (if state.config.cwd <> None then state.config.cwd else req.cwd) | ||
| (fun () -> |
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.
Capture/lock cwd for server requests
When the server is started without --cwd, config.cwd stays None, but requests are still allowed to supply a cwd and this path is used here for the analysis run. The reactive state (and runConfig) was initialized once in the original working directory, so accepting a request that switches cwd reuses cached state from a different project and can return incorrect diagnostics or crash while reading mismatched file paths. Consider recording the actual startup cwd in the server state (even when --cwd is omitted) and rejecting requests whose cwd differs from it, or disallowing req.cwd entirely when the server was initialized without --cwd.
Useful? React with 👍 / 👎.
- 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: |
Summary
Implements a long-lived reanalyze server that keeps reactive analysis state warm across requests, with transparent delegation - regular
reanalyzecalls automatically use the server if running.Key Features
reanalyzecalls automatically use the server if running on default socketResults
Quick Start: Try on Your Project
1. Build from this PR branch
2. In your project directory
Make sure the executables are available under node modules, in particular:
3. Experience the speedup
npx rescript build, then analysis is fast again4. Stop the server when done
Technical Details
/tmp/rescript-reanalyze.sock--cwdto absolute path for consistent matchingChanges
analysis/reanalyze/src/Reanalyze.ml: Server + client + transparent delegationanalysis/bin/main.ml: Dispatch for new subcommandsanalysis/reanalyze/README.md: Updated documentationtests/.../test-reactive-server.sh: Comprehensive test harness