Skip to content

Measure the data browser and plan its redesign - #333

Merged
jbearak merged 2 commits into
mainfrom
data-browser-phase-0
Oct 31, 2026
Merged

jbearak merged 2 commits into
mainfrom
data-browser-phase-0

Conversation

@jbearak

@jbearak jbearak commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Sight's data browser freezes the editor on big datasets: every sort, filter, histogram and copy runs on the extension host's event loop for its whole duration. On a 10M-row file a string sort blocks VS Code for 14.8 s; a slow regex filter, 29 s; a catastrophic one, until you kill the window. Opening a 1M × 500 survey file with strLs blocks for 0.66 s and ships a 5 MB first page. This PR is Phase 0 of a redesign: the plan, and the measurement every later phase is judged by. It changes no browser behavior.

The plan is specs/2026-10-30-data-browser-redesign.md, with a prior-art survey beside it. It ports selected pieces of Raven's viewer (radix and rank sort, scan worker, profiles, summary band, columns sidebar), keeps reading .dta directly, and keeps Stata semantics first-class. Claude Sonnet and GPT-6.1 Terra both agreed to it after six review rounds. Their objections, and the edits that answered them, are recorded in the spec. Phases after this one: 1a moves full-column work off the host (no dependency change), 1b moves to dta-parser 1.x with reader threads and a compact wire format, then truthful display, speed, column understanding, and navigation.

What this PR adds

  • bun run bench:data-browser (scripts/bench-data-browser/) generates Stata-shaped fixtures (10M × 10; 1M × 500 with labelled extended missings and strLs). It drives the real DataBrowserPanel under Node through a fake webview that serializes every message, as VS Code does. For each operation it reports time, the extension host's longest event-loop stall, reply size and peak RSS. --scale and Linux --cold are available.
  • bun run test:perf (in client) opens fixtures in a real VS Code and times each one to the first rows painted. It reads webview timing marks behind a new sight.dataBrowser.debugTiming setting (off by default), which also logs the marks for everyday diagnosis.
  • Display-truth and missing-identity test batteries. Behavior that already matches Stata is asserted. Today's gaps (%tdDD/NN/CCYY shows 21521, %th, %g width, missing codes not ordered . < .a < … < .z in a sort) are pinned to today's output, so the phase that fixes one fails its test on purpose.
  • A report-only CI job: the benchmark at 10% scale with the page cache dropped before every sample.
  • client/test/package.json ("type": "commonjs"). node client/test/runTest.js had not loaded since the ESM migration made client a module package; this restores the smoke and layout suites and hosts the new one.

Baseline (M4 Max, Node 26, warm cache; host blocked = longest event-loop stall)

10M × 10 1M × 500 with strL
Open → first page reply 3.7 ms 664 ms, all blocking; 5.2 MB; RSS 952 MiB
Open → first rows painted (in VS Code) 178–320 ms 645 ms, host blocked ~535 ms
Numeric sort 3,535 ms, blocked 3,533 ms 683 ms, blocked 681 ms
String sort 14,766 ms, blocked 14,764 ms 1,163 ms, blocked 1,161 ms
Numeric filter 529 ms, blocked 527 ms 354 ms, blocked 353 ms
Pathological regex filter 29,440 ms, blocked throughout killed at 120 s, blocked throughout
Histogram 541 ms, blocked 539 ms 367 ms, blocked 365 ms
Copy column 2,216 ms, blocked 2,214 ms 910 ms, blocked 908 ms
Restore saved sort + filter 4,123 ms, blocked 3,727 ms —

A page request in flight when a sort starts is dropped without a reply. The webview recovers only by re-requesting after the sort lands.

Checks. bun run check:line-endings, bun run typecheck and bun run lint pass. bun test ./tests passes except 2 tests in tests/integration/help-topic-coverage.test.ts, which need a local Stata install and fail the same way on main. bun run test:perf passed against an installed VS Code at 10% and full scale.

Reply sizes in the table were measured as UTF-16 code units; the harness now counts UTF-8 bytes, which is a little larger for the wide fixture's non-ASCII text.

Proof: all four repo gates were rerun after rebasing onto main (the only failures are the 2 tests that need Stata), and test:perf was run in a real VS Code.

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

Created with Claude Opus 5.5 in Claude Code; the plan was reviewed by Claude Sonnet 5.5 and GPT-6.1 Terra (Codex).

Summary by CodeRabbit

  • New Features
    • Added an optional data-browser timing setting that logs how long it takes for the first rows to appear.
  • Documentation
    • Added guidance on the timing setting and data-browser performance measurements.
  • Chores
    • Added automated data-browser performance reporting.

Add the redesign plan (specs/2026-10-30-data-browser-redesign.md,
agreed by two reviewers) and its prior-art survey, and the measurement
the plan's later phases are judged by:

- scripts/bench-data-browser: streams Stata-shaped 10M x 10 and
  1M x 500 (strL) fixtures, drives the real DataBrowserPanel under Node
  through a fake webview, and reports time, the extension host's
  longest event-loop stall, payload size and peak RSS per operation
  (bun run bench:data-browser; --scale, --cold).
- A VS Code-hosted suite that times each open to the first rows
  painted (client: bun run test:perf), fed by webview timing marks
  behind the new sight.dataBrowser.debugTiming setting.
- Display-truth and missing-identity batteries; today's gaps are
  pinned to today's output so a fix fails them on purpose.
- A report-only CI job at 10% scale with cold reads.

client/test/package.json scopes the CommonJS test runners, which have
not loaded under client's "type": "module" since the ESM migration.
@jbearak
jbearak force-pushed the data-browser-phase-0 branch from 430b061 to 219d311 Compare October 31, 2026 01:59
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request adds optional data-browser timing, a VS Code performance test suite, and benchmark tools for panel operations, reader paths, and browse-signal latency. It also adds CI reporting, benchmark documentation, behavior tests, and data-browser design documents.

Changes: Performance measurement

Layer / File(s) Summary
Host and webview timing
client/src/data-browser/*, client/package.json, docs/data-browser.md, tests/unit/data-browser/debug-timing.test.ts
The host and webview record timing marks through first-row paint. The optional setting logs elapsed times, and a command returns timing snapshots. Unit tests cover enabled and disabled timing behavior.
VS Code performance test and CI reporting
client/test/data-browser-perf/*, client/test/runTest.js, client/test/package.json, .github/workflows/ci.yml, DEVELOPMENT.md
The VS Code test opens configured fixtures and records timing marks and event-loop stalls. The runner can generate missing fixtures. CI runs a report-only benchmark job and appends the report when available.
Panel operation benchmark
scripts/bench-data-browser/bench.ts
A headless benchmark measures data-browser opening and operations such as sorting, scrolling, filtering, restore, histogram, and copy. It emits timing, response, stall, and memory metrics.
Fixture generation and benchmark driver
scripts/bench-data-browser/make-fixtures.ts, scripts/bench-data-browser/run.ts, scripts/bench-data-browser/vscode-stub.ts, package.json
The fixture generator writes scaled Stata datasets. The driver runs benchmark cases, aggregates results, and writes JSON and Markdown reports.
Reader and signal-latency benchmarks
scripts/bench-data-browser/reader-bench.ts, scripts/bench-data-browser/vview-latency.ts
The reader benchmark compares configured reader paths and a numeric scan. The signal benchmark measures signal-claim latency and can also measure a sequential write and fsync.

Data-browser behavior and design

Layer / File(s) Summary
Display and missing-value characterization
tests/unit/data-browser/display-truth.test.ts, tests/unit/data-browser/missing-identity.test.ts
Tests assert selected Stata-matching display cases, record known display gaps, and check numeric missing-value display, filtering, and sorting behavior.
Prior-art survey and redesign plan
specs/2026-10-30-data-browser-prior-art.md, specs/2026-10-30-data-browser-redesign.md
The survey compares existing data-browser approaches and lists requirements for Sight. The plan documents measured baselines and proposed architecture, display behavior, phases, and tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant PerfTest
  participant VSCodeEditor
  participant DataBrowserPanel
  participant WebviewTiming
  participant PerfTest
  PerfTest->>VSCodeEditor: open fixture with Sight editor
  VSCodeEditor->>DataBrowserPanel: create data-browser panel
  DataBrowserPanel->>WebviewTiming: send metadata with timing enabled
  WebviewTiming->>DataBrowserPanel: report metadata, first rows, and paint marks
  PerfTest->>DataBrowserPanel: request timing snapshot
  DataBrowserPanel-->>PerfTest: return timing records
Loading

Possibly related PRs

  • jbearak/sight#334: Updates the VS Code engine contract and fallback version used by the VS Code test path added here.
Merge Risk: Low · up to 219d3

This change adds measurement tooling and design documents without altering data-browser behavior. The benchmark fixture and harness can skew measurements, and the migration plan leaves rollback behavior underspecified; fix these before relying on the baselines or starting the redesign work.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@jbearak
jbearak merged commit 7cece0f into main Oct 31, 2026
13 of 14 checks passed
@jbearak
jbearak deleted the data-browser-phase-0 branch October 31, 2026 02:03
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