Skip to content

Mutations tab: one round of statements, bounded driver reads, no duplicate lollipop - #504

Merged
alisman merged 1 commit into
masterfrom
session/mutation-perf
Nov 25, 2026
Merged

alisman merged 1 commit into
masterfrom
session/mutation-perf

Conversation

@alisman

@alisman alisman commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A cold Mutations tab took 7.5s to draw on msk_chord_2024 TP53 and 9.7s on msk_impact_50k_2026 TP53, against about 3.5s on the pre-parity baseline (140c9239). Each load read 139–162M warehouse rows; the baseline read 43–54M. This PR makes five changes, and the answers stay the same.

What changed

  1. The gene chips' check shares the lollipop card's request.
    • The chips' "which genes are empty" view is the card's own view when there is one gene, and it ran in full a second time.
    • api.analysis now shares one in-flight request among callers that send the same path and body. Each caller gets a clone, and a caller's abort only abandons its own wait.
    • The check also asks with ?oncoprint=spec now, like the card, so it shares the card's cached answer.
  2. The lollipop's driver test reads only its genes and its study.
    • hotspotKeysSql filtered mutation_derived by studyId, which isn't in that table's sort key, so it read all 19M rows. It now also filters by the study's profile prefix, as the lollipop's own rows already do.
    • The OncoKB driver set is limited to the lollipop's genes. Before, it read 6.9M rows.
    • The OncoPrint's and OQL's driver filters use the same hotspot keys, so they read less too.
  3. The mutations view runs its statements at once when there is no search.
    • The default columns only matter for the columns a search reads. So without a search, the facts, counts, page and clinical Freq no longer wait for each other.
    • With a search, the facts still run first.
  4. runRows asks for one database's page alongside its counts. This applies to every table view.
    • An offset at or past the total still keeps no rows.
    • Several databases, or a located patient, still use the sequential walk.
    • A table whose count is 0 now also sends its page statement. This is the one extra statement in the timeline snapshot.
  5. The default columns' facts come from the counts statement.
    • countsSql takes columns to summarise over every row: a range, or up to VALUES_MAX distinct values.
    • runRows merges the summaries across parts, by column. The mutations view reads Allele Freq (T)'s and Cancer Type Detailed's facts from them, instead of running two more statements over the row source.
    • A backend whose counts carry no summaries falls back to the values statements.

Rules table

# Rule
S1 The counts' summaries cover every row of a part, whatever the query's search and filters. The query's n still follows the query.
S2 The summaries equal valuesSql's range and value set for the same column.
S3–S5 A column with no number gives a null range. More than 500 values sets truncated. An unknown column throws. No summarize leaves the statement unchanged.
S6–S7 The merge takes the widest range and the union of the values. It matches parts by column and is truncated if any part was.
P1–P5 runRows with one database asks for the page without waiting for the counts. An offset at the total gives no rows. Two databases, or locate, are sequential. Errors propagate with no unhandled rejection. Summaries are present only when every part carried them.
M1–M6 The mutations view reads its facts from the counts' summaries without a search, with no values query. Without summaries it falls back. With a search, the facts come first and the counts and page get their defaults. The clinical Freq is asked before the counts answer. There is no Freq on a later page or for a column's values. Failures refuse the view.
L1–L2 On the fixture, the hotspot keys and the lollipop's driver flags equal an oracle. A gene's flags don't depend on which other genes are asked.
C1–C5 Same path and body while in flight: one fetch. A different body or query: separate fetches. After it resolves: a new fetch. An abort only rejects its own caller. A failed fetch rejects every caller.

Verification

  • Same answers as master. /api/analysis was compared with the result cache off on nine study/gene pairs: msk_chord_2024 TP53, ALK, TMPRSS2 and KRAS; coadread KRAS and APC; msk_impact_2017 EGFR; msk_impact_50k_2026 TP53 and KRAS. Three things were checked:

    • the mutations table at 500 rows (every value, totals, shown and default columns, Copy #, including TMPRSS2's 315 fusion rows);
    • the table with a search;
    • the lollipop.

    All are identical. The one exception is the order of the lollipop's per-codon types array, which master also changes between two of its own runs.

  • Snapshots. The hotspots, mutcompare, mutations and timeline snapshots were recorded again against the warehouse. Their .json, .svg, .txt and .html outputs are unchanged; only the statements changed.

  • Tests. A separate agent wrote the tests from the table above, without the implementation in view. They fail on master where behaviour changed. The summaries and the driver reads are run on the fixture study.

    • npm test: 7,516 passed, 0 failed, including the fixture tests.
    • Seven planted bugs (scripts/mutants/mutations/tab-rounds.ts): all caught.
    • ESLint and knip pass.
  • Not run locally: the e2e gate. CI runs it on this PR.

Timings

Production builds, one page load at a time, a fresh server per round. Cold, fully drawn, median (min–max), n = 3:

baseline 140c9239 master this PR rows read: master → this PR
coadread KRAS 4.1s (2.5–4.4) 4.4s (4.1–4.8) 3.6s (3.4–4.4) 139M → 27M
msk_chord_2024 TP53 3.5s (3.3–3.8) 7.5s (6.7–7.6) 4.3s (4.1–4.6) 150M → 33M
msk_impact_50k_2026 TP53 3.6s (3.4–4.1) 9.7s (8.2–12.2) 4.8s (4.5–5.1) 162M → 41M

Warm loads are unchanged, at 0.7–1.0s. docs/PERFORMANCE.md has a new section with these numbers and with what was measured and did not help.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q3ezTZkR7ALApvELw1R6WL

@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cbiolab-genie Ready Ready Preview Nov 25, 2026 1:41am UTC
cbiolab-new Ready Ready Preview Nov 25, 2026 1:41am UTC
cohort-lab Ready Ready Preview Nov 25, 2026 1:41am UTC

Request Review

…icate lollipop

A cold Mutations tab ran its table in four rounds of statements, computed the lollipop twice and
read 139-162M warehouse rows per load (43-54M on the pre-parity baseline 140c923). Five changes:

- The chip check shares the lollipop card's request. With one gene the chips' "which genes are
  empty" view is the card's own view, and nothing deduplicated it. api.analysis now shares one
  in-flight request among callers sending the same path and body (each gets a clone; a caller's
  abort only abandons its own wait), and the check asks with ?oncoprint=spec like the card, so it
  also shares the card's cached answer.
- The lollipop's driver test reads only its genes and study. hotspotKeysSql filtered
  mutation_derived by studyId, which is not in its sort key, so it read all 19M rows of every
  study; it now also filters by the study's profile prefix, as the lollipop's own rows do. The
  OncoKB driver set is limited to the lollipop's genes (6.9M rows read before). The same keys are
  read by the OncoPrint's and OQL's driver filters.
- The mutations view runs its statements at once. Without a search the default columns reach no
  statement (they matter only for the columns a search reads), so the facts, counts, page and the
  clinical Freq no longer wait for each other. With a search the facts still come first.
- runRows asks for one database's page beside its counts (any table view). An offset at or past
  the total still keeps no rows. Several databases, or a located patient, keep the sequential
  walk. A table whose count is 0 now also sends its page statement.
- The default columns' facts come from the counts statement. countsSql takes columns to summarise
  over every row of each part (a range, or up to VALUES_MAX distinct values); runRows merges them
  across parts by column; the mutations view reads Allele Freq (T) and Cancer Type Detailed's facts
  from them instead of two more statements over the row source. A backend whose counts carry no
  summaries falls back to the values statements.

Verified: the mutations table (500 rows; and with a search) and the lollipop return the same
answers as master for msk_chord_2024 TP53/ALK/TMPRSS2/KRAS, coadread KRAS/APC, msk_impact_2017
EGFR and msk_impact_50k_2026 TP53/KRAS (the lollipop's `types` order aside, which master varies
between its own runs). The hotspots, mutcompare, mutations and timeline snapshots were recorded
again against the warehouse: their outputs are unchanged, only the statements moved. Tests were
written from the rules' table by a separate agent and failed on master where behaviour changed;
the summaries and driver reads are run on the fixture study. Seven planted bugs
(scripts/mutants/mutations/tab-rounds.ts) are all caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q3ezTZkR7ALApvELw1R6WL
@alisman
alisman force-pushed the session/mutation-perf branch from 1ca99a8 to aff6c35 Compare November 25, 2026 01:40
@alisman
alisman merged commit 7a9f21a into master Nov 25, 2026
12 of 13 checks passed
@alisman
alisman deleted the session/mutation-perf branch November 25, 2026 01:56

This branch was successfully deployed

1 active deployment
Preview – cohort-lab — aff6c358 Deployed Nov 25, 2026 by vercel[bot]
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