Skip to content

Record the TSP requests Pylance sends on a slow PyTorch file - #5439

Open
kinto0 wants to merge 1 commit into
mainfrom
kinto0/tsp-bench-1-record
Open

kinto0 wants to merge 1 commit into
mainfrom
kinto0/tsp-bench-1-record

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/record/, which runs the latest VS Code and Pylance headless with pyrefly as the type server, opens torch/_inductor/ir.py in the pinned PyTorch checkout, and drives a hover, a completion, and an idle re-check after edits. It writes every TSP request Pylance sent to benches/tsp/traces/, one file per feature (cold_start, hover, completion, recheck; ~1 MB in total, checked in), so that each benchmark loads only its own trace and a re-recording diffs per feature.
  • Why: TSP benchmarks need the requests a real client sends. Hand-written sequences guess wrong: Pylance sends no requests for a repeated hover (it caches types until the snapshot changes), never sends getDeclaredType, and re-checks the whole file over TSP after every edit and on open.
  • Foreground requests come from pyrefly's stdin. Background-checker requests go over an extra connection, so they come from Pylance's own TSP log, which the runner copies as it grows because VS Code rotates it every 5 MB.

Test Plan:
On a devserver with internet through fwdproxy (Pylance 2026.4.1, VS Code 1.144.0):

HTTPS_PROXY=http://fwdproxy:8080 benches/tsp/record/record.sh <pyrefly> <pinned PyTorch checkout>
startup: 17494 requests
hover: 33 requests
completion: 79 requests
recheck: 16462 requests

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

- What: add `benches/tsp/record/`, which runs the latest VS Code and Pylance headless with pyrefly as the type server, opens `torch/_inductor/ir.py` in the pinned PyTorch checkout, and drives a hover, a completion, and an idle re-check after edits. It writes every TSP request Pylance sent to `benches/tsp/traces/`, one file per feature (`cold_start`, `hover`, `completion`, `recheck`; ~1 MB in total, checked in), so that each benchmark loads only its own trace and a re-recording diffs per feature.
- Why: TSP benchmarks need the requests a real client sends. Hand-written sequences guess wrong: Pylance sends no requests for a repeated hover (it caches types until the snapshot changes), never sends `getDeclaredType`, and re-checks the whole file over TSP after every edit and on open.
- Foreground requests come from pyrefly's stdin. Background-checker requests go over an extra connection, so they come from Pylance's own TSP log, which the runner copies as it grows because VS Code rotates it every 5 MB.

Test Plan:
On a devserver with internet through fwdproxy (Pylance 2026.4.1, VS Code 1.144.0):
```
HTTPS_PROXY=http://fwdproxy:8080 benches/tsp/record/record.sh <pyrefly> <pinned PyTorch checkout>
startup: 17494 requests
hover: 33 requests
completion: 79 requests
recheck: 16462 requests
```
@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D128211225. (Because this pull request was imported automatically, there will not be any future comments.)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant