perf: add timing instrumentation to worksheet page SSR

Track where time is spent during worksheet page render:
- loadWorksheetSettings (DB query + getViewerId)
- generateWorksheetPreview (problem generation + Typst compilation)
- Total page render time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2026-01-23 14:21:07 -06:00
parent b04d0caeaf
commit 1f1083773d
4 changed files with 51 additions and 2 deletions

View File

@ -700,7 +700,33 @@
"Bash(terraform force-unlock:*)",
"Bash(kubectl:*)",
"Bash(terraform validate:*)",
"Bash(terraform fmt:*)"
"Bash(terraform fmt:*)",
"Bash(ab:*)",
"Bash(for i in {1..5})",
"Bash(do curl -s -o /dev/null -w \"%{time_total}s\\\\n\" https://abaci.one/api/health)",
"Bash(do curl -s -o /dev/null -w \"%{time_total}s\\\\n\" https://abaci.one/)",
"Bash(for:*)",
"Bash(do curl -s -o /dev/null -w \"DNS: %{time_namelookup}s | App: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/)",
"Bash(do curl -s -o /dev/null -w \"App: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/)",
"Bash(do curl -s -o /dev/null -w \"App: %{time_starttransfer}s\\\\n\" https://abaci.one/api/health)",
"Bash(do curl -s -o /dev/null -w \"App: %{time_starttransfer}s\\\\n\" https://abaci.one/)",
"Bash(do curl -s -o /dev/null -w \"%{time_starttransfer}s\\\\n\" https://abaci.one/api/health)",
"Bash(do curl -s -o /dev/null -w \"%{time_starttransfer}s\\\\n\" https://abaci.one/)",
"Skill(porkbun-dns)",
"Bash(export KUBECONFIG=/Users/antialias/.kube/k3s-config:*)",
"Bash(do curl -s -o /dev/null -w \"DNS: %{time_namelookup}s | Connect: %{time_connect}s | TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/)",
"Bash(__NEW_LINE_4217313881615341__ echo \"Testing with HTTP/1.1...\")",
"Bash(__NEW_LINE_4217313881615341__ sleep 2)",
"Bash(__NEW_LINE_4217313881615341__ echo \"Testing Expert with HTTP/1.1...\")",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/api/health)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/games)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/flashcards)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/create/worksheets)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/dashboard)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/tutorials)",
"Bash(do curl -s -o /dev/null -w \"TTFB: %{time_starttransfer}s | Total: %{time_total}s\\\\n\" https://abaci.one/favicon.ico)",
"Bash(ping:*)"
],
"deny": [],
"ask": []

1
.gitignore vendored
View File

@ -62,3 +62,4 @@ storybook-static
apps/web/data/sqlite.db.backup.*
# Vision training data
data/vision-training/
infra/terraform/tfplan

View File

@ -105,7 +105,21 @@
"Bash(tr:*)",
"mcp__chrome-devtools__close_page",
"mcp__chrome-devtools__press_key",
"Bash(git reset:*)"
"Bash(git reset:*)",
"Bash(npm run typecheck:*)",
"Bash(npm run tsc:*)",
"Bash(npx eslint:*)",
"Bash(npx prettier:*)",
"Bash(awk:*)",
"Bash(mcp__sqlite__read_query:*)",
"WebFetch(domain:github.com)",
"WebFetch(domain:mermaid.ai)",
"mcp__chrome-devtools__hover",
"mcp__chrome-devtools__list_network_requests",
"mcp__chrome-devtools__get_network_request",
"Bash(npm run db:push:*)",
"Bash(kubectl get:*)",
"Bash(kubectl logs:*)"
],
"deny": [],
"ask": []

View File

@ -81,7 +81,12 @@ async function loadWorksheetSettings(): Promise<
}
export default async function AdditionWorksheetPage() {
const pageStart = Date.now()
console.log('[SSR] Starting worksheet page render...')
const settingsStart = Date.now()
const initialSettings = await loadWorksheetSettings()
console.log(`[SSR] loadWorksheetSettings: ${Date.now() - settingsStart}ms`)
// Calculate derived state needed for preview
// Use defaults for required fields (loadWorksheetSettings should always provide these, but TypeScript needs guarantees)
@ -105,7 +110,10 @@ export default async function AdditionWorksheetPage() {
const INITIAL_PAGES = 3
const pagesToGenerate = Math.min(INITIAL_PAGES, pages)
console.log(`[SSR] Generating initial ${pagesToGenerate} pages on server (total: ${pages})...`)
const previewStart = Date.now()
const previewResult = await generateWorksheetPreview(fullConfig, 0, pagesToGenerate - 1)
console.log(`[SSR] generateWorksheetPreview: ${Date.now() - previewStart}ms`)
console.log(`[SSR] Total page render: ${Date.now() - pageStart}ms`)
console.log('[SSR] Preview generation complete:', previewResult.success ? 'success' : 'failed')
// Pass settings and preview to client, wrapped in error boundary