Skip to content

test(web): keep FakeHappyView's SQLite temp tables in memory - #254

Merged
botandbang merged 1 commit into
mainfrom
bnb/budget-test-speed
Oct 25, 2026
Merged

botandbang merged 1 commit into
mainfrom
bnb/budget-test-speed

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

directory.test.ts > instruction budget took anywhere from 31 s to over 250 s and timed out at 120 s on loaded machines, on main too. SQLite writes the temporary b-trees of materialized CTEs and sorts to files in $TMPDIR by default, even for a :memory: database. The support queries (getCharts, getArtist, searchArtists) spilled about 15 MB per query there, so their wall time followed whatever else was using the disk, while their CPU time stayed under a second each.

Changed: FakeHappyView (src/lib/server/testing/happyview.ts) runs PRAGMA temp_store = MEMORY before its schema. Results and instruction counts are the same, and the test, its assertions and its timeout are unchanged. Production is untouched: this is the test harness only.

How it was tested

  • The test now takes 4 to 6 s alone, and up to 21 s while three loops of the full server suite run alongside it
  • pnpm vitest run --project server, pnpm check, pnpm lint, pnpm knip, pnpm format:check, and pnpm test:integration against HappyView 2.16

Checklist

  • Tests cover the change
  • For the website: Storybook stories cover any new UI states
  • For locallibrary: apps/locallibrary/CHANGELOG.md has a line under Unreleased, if people using it will notice
  • The READMEs, docs/ and --help still say what the code does

SQLite writes the temp b-trees of materialized CTEs and sorts to files in $TMPDIR by default, even for a :memory: database. The support queries in the instruction budget test spilled about 15 MB per query there, so their wall time followed disk contention from other processes (31 s to over 250 s, timing out at 120 s) while CPU time stayed under a second each. With temp_store = MEMORY the test takes 4 to 6 s, and results and instruction counts are unchanged.
@botandbang
botandbang requested a review from bnb as a code owner October 25, 2026 19:44
@github-actions github-actions Bot added web The Local Network website (apps/web) web: server Spaces, sync, HappyView, the database and the server around them tests Tests, fixtures and test harnesses labels Oct 25, 2026
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Coverage Report for apps/web

Status Category Percentage Covered / Total
🟢 Lines 94.28% (🎯 93%)
🟰 ±0 pp
5826 / 6179
🟢 Statements 92.66% (🎯 91%)
🟰 ±0 pp
9015 / 9729
🟢 Functions 93.26% (🎯 92%)
🟰 ±0 pp
2286 / 2451
🟢 Branches 81.97% (🎯 80%)
🟰 ±0 pp
4158 / 5072
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/web/src/lib/server/testing/happyview.ts 92.75%
⬆️ +0.03 pp
86.2%
🟰 ±0 pp
97.14%
🟰 ±0 pp
94.8%
⬆️ +0.02 pp
166, 171, 193, 213-217, 274, 343, 361, 392, 406, 481, 506-517, 539
Generated in workflow #476 for commit af86fe6 by the Vitest Coverage Report Action

Size

Compared with main. KiB are 1,024 bytes.

This pull request main Change
Client JavaScript 619.1 KiB 619.1 KiB 0 B (0%)
Client JavaScript, brotli 204.5 KiB 204.5 KiB 0 B (0%)
Client CSS 87.6 KiB 87.6 KiB 0 B (0%)
Client CSS, brotli 12.5 KiB 12.5 KiB 0 B (0%)

@botandbang
botandbang merged commit 77235a9 into main Oct 25, 2026
50 checks passed
@botandbang
botandbang deleted the bnb/budget-test-speed branch October 25, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests, fixtures and test harnesses web: server Spaces, sync, HappyView, the database and the server around them web The Local Network website (apps/web)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants