Back to Prisma

Benchmark Improvements Task Index

docs/plans/benchmark-improvements/000-benchmark-improvements-index.md

7.9.0-dev.45.2 KB
Original Source

Benchmark Improvements Task Index

Overview

This directory contains executable task plans for improving Prisma's query and compilation performance benchmark suite. The tasks cover migration to modern tooling, benchmark refinement, documentation, and establishing performance baselines.

Task Summary

IDTaskPriorityStatusDependencies
001Migrate from Benchmark.js to TinybenchHighPlannedNone
002Bump CodSpeed Plugin to v5.xMediumPlannedNone (skip if doing 001)
003Review Query Performance BenchmarksMediumPlannedNone
004Review Interpreter BenchmarksMediumPlannedNone
005Establish Performance BaselinesHighPlanned001, 003, 004
006Update Benchmarking DocumentationMediumPlanned001, 005
007Clean Up Legacy Benchmark CodeLowPlanned001

Phase 1: Migration (Required First)

  1. Task 001 - Migrate from Benchmark.js to Tinybench
    • Updates all benchmark files to use modern async/await patterns
    • Replaces deprecated library with actively maintained alternative
    • CodSpeed plugin automatically updated to v5.x

Phase 2: Refinement (Can Parallelize)

  1. Task 003 - Review Query Performance Benchmarks
  2. Task 004 - Review Interpreter Benchmarks
    • These can be done in parallel
    • Focus on coverage, accuracy, and real-world patterns

Phase 3: Baseline & Documentation

  1. Task 005 - Establish Performance Baselines

    • Run after benchmark refinements are complete
    • Documents expected performance ranges
    • Configures CI alerting thresholds
  2. Task 006 - Update Benchmarking Documentation

    • Reflects tinybench migration
    • Includes baseline measurements
    • Updates all code examples

Phase 4: Cleanup

  1. Task 007 - Clean Up Legacy Benchmark Code
    • Removes deprecated patterns
    • Applies consistent code style
    • Final polish

Current State Analysis

What's Been Implemented

  • ✅ End-to-end query performance benchmarks (query-performance.bench.ts)
  • ✅ Query compilation benchmarks (compilation.bench.ts)
  • ✅ Interpreter and data mapper benchmarks (interpreter.bench.ts)
  • ✅ Comprehensive schema with web app models
  • ✅ Configurable seed data (small/medium/large)
  • ✅ CI workflow with CodSpeed integration
  • ✅ Documentation (docs/benchmarking.md)
  • ✅ AGENTS.md updated with benchmarking section

What's Missing or Needs Improvement

  • ❌ Using legacy Benchmark.js (unmaintained since 2016)
  • ❌ CodSpeed plugin is outdated (4.0.0 → 5.0.1)
  • ❌ Some query patterns not covered (raw queries, cursor pagination)
  • ❌ No documented performance baselines
  • ❌ Some benchmark files have @ts-nocheck and other suppressions
  • ❌ Inconsistent async patterns (deferred callbacks vs async/await)

Quick Reference

Run All Benchmarks

bash
pnpm bench

Run Specific Benchmarks

bash
pnpm bench query-performance
pnpm bench compilation
pnpm bench interpreter

Benchmark Locations

BenchmarkLocation
Query Performancepackages/client/src/__tests__/benchmarks/query-performance/query-performance.bench.ts
Compilationpackages/client/src/__tests__/benchmarks/query-performance/compilation.bench.ts
Interpreterpackages/client-engine-runtime/bench/interpreter.bench.ts
Client Generationpackages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts
Relations Generationpackages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts
Platform Detectionpackages/get-platform/bench/get-platform.bench.ts

Key Dependencies

CurrentTarget
@codspeed/[email protected]@codspeed/[email protected]
[email protected]tinybench@^4.0.1

Notes

  • Task 002 (bump CodSpeed version) can be skipped if completing Task 001 (tinybench migration)
  • Performance baselines should be re-established after any significant benchmark changes
  • All tasks should be verified in CI before marking complete
  • Keep tasks small and focused for easier review and iteration