codeflash-internal/.codeflash/results.tsv
Kevin Turcios d7a8b8f227
perf: fix CI build + lazy-load heavy libs + parallelize DB queries (#2601)
## Summary
- **Fix CI build failure**: Auth0Client crashes during Next.js
prerendering when env vars aren't set. Returns a no-op stub (`getSession
→ null`) when domain is missing — semantically correct for static
generation
- **Lazy-load markdown libs (~260kb)**: ReactMarkdown, remarkGfm, and
react-syntax-highlighter were eagerly imported in monaco-diff-viewer but
only rendered when user expands "Generated Tests". Extracted into a
dynamic component
- **Parallelize repo detail query**: `getRepositoryById` ran the
activity count sequentially after the repo lookup. Since `repoId` is
already available, all three queries now run in parallel

## Test plan
- [ ] CI `build` check passes (was failing since #2598)
- [ ] Trace page still renders generated tests correctly when expanded
- [ ] Repository detail page loads correctly with activity status
2026-04-13 11:03:05 -05:00

6.1 KiB

1committargetdescriptionstatusdomainsinteraction
213b302a8members/action.tsfindFirst->findUnique on composite index, parallel permission checks instead of loading all members (5 functions)keepquery,structureindex-seek replaces table-scan
313b302a8repositories/action.tsfindFirst->findUnique, parallel permission checks, select narrowing (5 functions)keepquery,structureindex-seek replaces table-scan
413b302a8members/data.tsfindFirst->findUnique for org lookupkeepquerysingle-row PK seek
513b302a8privacy-actions.tsfindFirst->findUnique with composite key + selectkeepqueryindex-seek replaces scan
613b302a8review-optimizations/action.tsSet-based lookup replacing Array.somekeepcpuO(1) vs O(n) per item
713b302a8get-recent-traces.tsMap-based lookup replacing Array.find in loopkeepcpuO(1) vs O(n) per item
813b302a8llm-calls/page.tsxCombined 2 sequential Promise.all into 1 parallel batchkeepasyncreduced sequential waterfall
913b302a8traces/page.tsxParallelized 2 independent sequential querieskeepasyncreduced sequential waterfall
10a14cd8e7data.ts+repo-detail-client.tsxConsolidated 2 separate count queries into single combined querykeepquery2 roundtrips to 1
1116fc8856review-optimizations/action.tsNarrowed repository include from all columns to 3 needed fieldskeepqueryreduced data transfer
1222ef695c[traceId]/action.tsNarrowed repository include to id,full_name,name,installation_idkeepqueryreduced data transfer
137fcbd321llm-calls/page.tsxHoisted cached filter queries into main Promise.allkeepasynceliminated waterfall stage
14972846abmembers/data.tsEliminated redundant findUnique for current user rolekeepquery1 roundtrip eliminated
15f8686933[traceId]/action.tsAdded select:{metadata:true} to saveOptimizationChanges findUniquekeepqueryreduced data transfer
16cb384315auth0.tsParallelized trackUserLogin and hasCompletedOnboarding in login callbackkeepasyncreduced login latency
17bc715120dashboard/action.tsRewrite statistics CTE to use UNION instead of 3-way OR for personal accountskeepquery3 index-backed scans replace bitmap OR merge
182444d1b4dashboard/action.tsRewrite PR data query to use UNION CTE for personal accountskeepquery3 index-backed scans replace bitmap OR merge
196f9e81a6cached-dashboard-data.tsSelect only id,name from organizations (skips description, website, github_org_id, etc.)keepqueryreduced data transfer
206f9e81a6dashboard/action.tsSelect only id,name from organizations in getUserOrganizationskeepqueryreduced data transfer
216f9e81a6members/action.tsSelect only id+members from organizations in getOrganizationMemberskeepqueryreduced data transfer
226f9e81a6members/data.tsSelect only id+members from organizations in getMembersPageInitDatakeepqueryreduced data transfer
236f9e81a6llm-call/[id]/page.tsxSelect 6 fields from optimization_errors (skips stack_trace Text column)keepqueryreduced data transfer
246f9e81a6get-trace-data.tsSelect only 6 consumed fields from optimization_errors (was 4, fixed to 6)keepqueryreduced data transfer
257221d448get-trace-data.tsSelect 12 fields from optimization_features instead of all 30+ columnskeepqueryreduced data transfer - skips large JSON/Text columns
261ef61d1ellm-call/[id]/page.tsxSelect 22 fields from llm_calls instead of all 30 (skips messages, parsed_response, context JSON blobs)keepqueryreduced data transfer - large JSON excluded
27bcaf08b5traces/page.tsxStore timestamps as numbers during aggregation, convert to Date once per trace at endkeepcpu,memoryavoids 2 Date objects per call per existing trace
28d6cab273llm-calls/loading.tsx + llm-call/[id]/loading.tsxAdd streaming loading skeletons for observability pages without internal Suspensekeepasyncinstant shell streaming while server component data fetches resolve
29ee535ae9dashboard/action.tsRestructure getOptimizationPRs: LIMIT before JOIN to optimization_features/repositorieskeepqueryJOINs only for ~10 result rows instead of all candidates
30ab15d0b5review-optimizations/action.tsWrap getRepositoriesWithStagingEvents + getAllOptimizationEvents with React cache() for request-level deduplicationkeepasync,queryeliminates 7-8x duplicate calls per request (9.1s + 15.4s → 3.5s expected)
311a57228creview-optimizations/action.tsRewrite getRepositoriesWithStagingEvents and getAllOptimizationEvents to use UNION queries for personal accountskeepquery3 index-backed scans replace bitmap OR merge (1633ms+1939ms → expected <1200ms total)
32PENDINGtraces/page.tsxRewrite getDistinctTraces as raw SQL CTE to use [trace_id, created_at DESC] index for GROUP BYkeepqueryleverages composite index for MAX aggregation (expected 616ms → <200ms)
33PENDINGtraces/page.tsxRewrite getUniqueOrganizations as raw SQL to use partial index on (organization WHERE NOT NULL)keepquerypartial index scan replaces full table scan (expected 727-980ms → <100ms)
34PENDINGcommon/prisma/migrationsAdd partial index on optimization_features(organization) WHERE organization IS NOT NULLkeepquerycovers DISTINCT organization query with smaller index
35PENDINGreview-optimizations/action.tsFix groupBy type annotation for organization account pathkeepstructureresolve TS2345 type error
36PENDINGdashboard/action.tsReplace EXISTS subqueries with LEFT JOIN in getOptimizationPRs count query (org + personal)keepqueryavoids row-by-row EXISTS evaluation (expected 921ms → <300ms)
37PENDINGdashboard/action.tsReplace EXISTS subqueries with LEFT JOIN in getOptimizationPRs data query (org + personal)keepqueryavoids row-by-row EXISTS evaluation (expected 1435ms → <500ms)
38PENDINGapikeys/page.tsxRewrite getCachedApiKeys as UNION query to avoid OR with nested EXISTSkeepquery2 index-backed scans replace bitmap OR merge (expected 787ms → <250ms)
39PENDINGcommon/user-functions.tsAdd getUserDashboardData to consolidate 4 separate user querieskeepquery4 roundtrips → 2 (onboarding, privacy, isPaid, subscription)
40PENDINGcached-dashboard-data.tsUse getUserDashboardData to eliminate separate user/subscription querieskeepqueryreduces cold-load query count from 5 → 2