Skip to content

Benchmark TSP against LSP for hover, completion, and recheck on PyTorch - #5440

Open
kinto0 wants to merge 1 commit into
kinto0/tsp-bench-1-recordfrom
kinto0/tsp-bench-2-warm
Open

kinto0 wants to merge 1 commit into
kinto0/tsp-bench-1-recordfrom
kinto0/tsp-bench-2-warm

Conversation

@kinto0

@kinto0 kinto0 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Stack (review and merge in order):

Stack context: TSP vs pyrefly LSP latency benchmarks on PyTorch.

  • What: add benches/tsp/pytorch.rs to tsp_bench. Each sample edits torch/_inductor/ir.py and serves one feature through the language server (lsp) and through the type server (tsp), which replays the recorded Pylance requests for the same feature from benches/tsp/traces/:
    • tsp/pytorch_hover: hover on guard_or_false. Pylance: 33 requests (getSnapshot, one resolveImport per import, getComputedType).
    • tsp/pytorch_completion: completion after V.graph.sizevars.. Pylance: 79 requests.
    • tsp/pytorch_recheck: the diagnostics of the file. LSP: textDocument/diagnostic. Pylance: the ~16.5k getComputedType requests that its background checker sends after every edit.
  • Why: a TSP client turns one IDE action into many TSP requests, so TSP latency can regress without any LSP benchmark moving.
  • Both servers run in process, driven by the shared pyrefly_lsp_test client, with the same pinned-checkout resource as pytorch_bench. The replay fills in the current snapshot and retries on snapshot outdated, as Pylance does. Each request stream is measured alone, although in Pylance the background checker shares the server's queue with hover and completion.

Test Plan:

PYREFLY_LOG=off buck2 run @fbcode//mode/opt fbcode//pyrefly/pyrefly:tsp_bench -- --bench --noplot pytorch_
group lsp tsp
tsp/pytorch_hover 331 ms 325 ms
tsp/pytorch_completion 329 ms 332 ms
tsp/pytorch_recheck 334 ms 1.04 s
Stack context: TSP vs pyrefly LSP latency benchmarks on PyTorch.

- What: add `benches/tsp/pytorch.rs` to `tsp_bench`. Each sample edits `torch/_inductor/ir.py` and serves one feature through the language server (`lsp`) and through the type server (`tsp`), which replays the recorded Pylance requests for the same feature from `benches/tsp/traces/`:
  - `tsp/pytorch_hover`: hover on `guard_or_false`. Pylance: 33 requests (`getSnapshot`, one `resolveImport` per import, `getComputedType`).
  - `tsp/pytorch_completion`: completion after `V.graph.sizevars.`. Pylance: 79 requests.
  - `tsp/pytorch_recheck`: the diagnostics of the file. LSP: `textDocument/diagnostic`. Pylance: the ~16.5k `getComputedType` requests that its background checker sends after every edit.
- Why: a TSP client turns one IDE action into many TSP requests, so TSP latency can regress without any LSP benchmark moving.
- Both servers run in process, driven by the shared `pyrefly_lsp_test` client, with the same pinned-checkout resource as `pytorch_bench`. The replay fills in the current snapshot and retries on `snapshot outdated`, as Pylance does. Each request stream is measured alone, although in Pylance the background checker shares the server's queue with hover and completion.

Test Plan:
```
PYREFLY_LOG=off buck2 run @fbcode//mode/opt fbcode//pyrefly/pyrefly:tsp_bench -- --bench --noplot pytorch_
```
| group | lsp | tsp |
|---|---|---|
| `tsp/pytorch_hover` | 331 ms | 325 ms |
| `tsp/pytorch_completion` | 329 ms | 332 ms |
| `tsp/pytorch_recheck` | 334 ms | 1.04 s |

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant