Skip to content

Keep VS Code responsive during data browser sorts, filters and copies (Phase 1a) - #336

Merged
jbearak merged 1 commit into
mainfrom
data-browser-phase-1a
Oct 31, 2026
Merged

jbearak merged 1 commit into
mainfrom
data-browser-phase-1a

Conversation

@jbearak

@jbearak jbearak commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Every sort, filter, histogram and copy in Sight's data browser ran on the extension host's event loop, so VS Code froze for the whole operation. On a 10M-row file, a string sort blocked the editor for 14.8 s, and a slow regex filter for 29 s. A catastrophic regex never finished, and the only way out was killing the window. This is Phase 1a of the redesign planned in #333: all of that work now runs in worker threads, the editor stays responsive, and slow work can be cancelled.

What changes for users

  • Sorting, filtering, the filter editor's histogram, reapplying a saved sort or filter on open, and Copy column run in short-lived worker threads. Scrolling, the grid and the rest of VS Code keep working meanwhile.
  • After half a second, the "Sorting…" / "Filtering…" line offers Cancel, which stops the work at once and keeps the current order. A new sort replaces a sort still running (likewise filters) instead of queueing behind it. Work still running after 10 minutes is stopped, with a message.
  • Copy column copies the order that was on screen when you clicked it, even if a sort finishes meanwhile.
  • A page read discarded because the order changed is now answered (rowsStale), and the grid asks again. Before, the page stayed blank until the next sort or filter finished.
  • vview temp files now stay in ~/.sight/browse/ until their panel closes, because the workers reopen them by path (dta-parser 0.6 can't share a descriptor). A <uuid>.lease beside each one, refreshed while the panel is open, keeps other windows' 24-hour cleanup from deleting it. The panel deletes its own file when it closes.
  • If the file on disk changes after the panel opened it, a sort or filter is not applied, and Sight asks you to reopen the dataset. Workers compare inode, size and mtime with what the host saw at open.

How. compute-jobs.ts holds the job logic, unchanged algorithms lifted out of browser-panel.ts. compute-worker.ts runs one job per worker, bundled as dist/data-browser-worker.js. compute-runner.ts manages two pools (two slots for sorts and filters, two for copies and histograms) and cancels by terminate(). Without the bundle (unit tests, an unbuilt checkout) the same jobs run in-process. The panel's existing restore and action-queue state machine is kept. The spec's 1a row described more machinery: a cooperative scan worker, per-filter steps, order_epoch on the wire. "Phase 1a as built" at the end of the spec records what shipped instead, and which phase picks up the rest.

Benchmark (M4 Max, Node 26, warm cache, full-scale fixtures; host blocked = the host's longest event-loop stall)

Operation Host blocked before Host blocked after Time after
narrow numeric sort (10M) 3,533 ms 7.4 ms 3,746 ms
narrow string sort 14,764 ms 8 ms 14,944 ms
narrow numeric filter 527 ms 6.7 ms 484 ms
narrow catastrophic regex blocked until done (29 s+) 8.4 ms over 3 s; Cancel in 0.5 ms —
narrow histogram 539 ms 5.7 ms 598 ms
narrow copy column 2,214 ms 10.3 ms 2,580 ms
narrow restore sort + filter 3,727 ms 16.4 ms 3,924 ms
wide numeric sort (1M × 500) 681 ms 0.6 ms 494 ms
wide strL regex killed at 120 s 1.1 ms over 3 s; Cancel in 0.3 ms —
wide copy column 908 ms 0.9 ms 426 ms
scroll during a sort, pages dropped 1 per sort, never answered 0 (1 answered stale) —

Wall times are unchanged, since these are the same algorithms on the same reader. Peak RSS stays within 1a's budget: 979 MiB for the narrow sort (961 before), and 2,413 MiB for the wide strL filter (budget ≤ 2.5 GiB until 1b). Page reads still run on the host, so the wide file's first 5 MB page still stalls for about 620 ms; Phase 1b moves those reads off the host.

Checks. bun run check:line-endings, bun run typecheck and bun run lint pass. bun test ./tests: 8,009 pass, plus the 2 help-coverage tests that need a local Stata install (failing the same way on main). New tests cover: a real worker computing the same order as in-process; a stuck regex stopped within 250 ms; the deadline; a changed file; pool limits; dispose; Cancel dropping queued work; a newer sort superseding a running one; rowsStale; the pinned copy order; closing mid-refresh; the lease and the sweep.

Proof: in a downloaded VS Code 1.123.0, the bundled worker ran inside the extension host. It sorted 10M rows in 3.5 s, filtered them in 0.4 s, and was terminated 505 ms into a catastrophic regex. bun run test:perf passes there too (narrow first rows painted at 404 ms, wide at 296 ms, 10% scale). The full benchmark above was run on this branch.

Reviewed with sol-loop: 3 rounds with gpt-6.1-sol. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 77 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 8cf5cebc-07f8-4c71-8140-c527dbeabf61
Commits

Reviewing files that changed from the base of the PR and between 6003bed and 6a2665b.

Files selected for processing: 23
  • client/package.json
  • client/src/data-browser/browse-lease.ts
  • client/src/data-browser/browser-panel.ts
  • client/src/data-browser/compute-jobs.ts
  • client/src/data-browser/compute-protocol.ts
  • client/src/data-browser/compute-runner.ts
  • client/src/data-browser/compute-worker.ts
  • client/src/data-browser/custom-editor.ts
  • client/src/data-browser/panel-manager.ts
  • client/src/data-browser/signal-watcher.ts
  • client/src/data-browser/types.ts
  • client/src/data-browser/webview/app.tsx
  • client/src/data-browser/webview/row-request-tracker.ts
  • client/src/data-browser/webview/styles.css
  • client/src/data-browser/webview/use-row-loader.ts
  • docs/data-browser.md
  • scripts/bench-data-browser/bench.ts
  • scripts/bench-data-browser/run.ts
  • specs/2026-10-30-data-browser-redesign.md
  • tests/unit/data-browser/browser-panel.test.ts
  • tests/unit/data-browser/compute-runner.test.ts
  • tests/unit/data-browser/restore-cancel.test.ts
  • tests/unit/data-browser/startup-cleanup.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@jbearak
jbearak force-pushed the data-browser-phase-1a branch from a38cba6 to 6a2665b Compare October 31, 2026 02:14
@jbearak
jbearak merged commit 4081455 into main Oct 31, 2026
12 checks passed
@jbearak
jbearak deleted the data-browser-phase-1a branch October 31, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant