prisma icon indicating copy to clipboard operation
prisma copied to clipboard

perf(client): expose Prisma Client performance branch

Open tensordreams opened this issue 5 months ago • 2 comments

Summary

Draft status PR for the Prisma repo side of the ongoing Prisma Client performance work. This branch contains the ClientEngine/runtime, generated exact/prepared helper, benchmark harness, and persistent performance-report changes that pair with the sibling engines branch.

This is intentionally not merge-ready as a final review unit. The branch is currently large (749 commits ahead, 1 commit behind fresh main) because it accumulated accepted experiments, rejected-experiment records, benchmark probes, and runtime changes during the investigation. I am opening it now so CI and reviewers can see the real state, then the next packaging step should be slicing it into smaller stacked PRs if this is too much to review at once.

Sibling engines PR: https://github.com/prisma/prisma-engines/pull/5820

Extracted engines child PRs:

  • https://github.com/prisma/prisma-engines/pull/5821
  • https://github.com/prisma/prisma-engines/pull/5822

Current split plan in this branch: wip/client-performance-pr-stack.md.

Linked Engines Branch for CI

The Prisma workflow reads this command from the PR body and builds native engines plus Wasm packages from the sibling engines branch:

/engine-branch prisma-client-performance-2026-06-08-engines

This intentionally blocks merge until the command is removed and tests are rerun with default engines. The sibling engines PR uses /prisma-branch prisma-client-performance-2026-06-08.

Main Contents

  • Query-plan cache and compact lockstep internal plan consumption.
  • ClientEngine/runtime support for raw-nested relation ops and final-owner schedule markers.
  • Generated exact descriptor helpers and generated prepared cache-hit helpers for strict internal shapes.
  • Edge/Workerd call-surface and plain-delegate improvements for extension-free generated clients.
  • Focused Node and Miniflare/workerd performance probes.
  • Persistent journal and intermediate performance report under wip/.

Current Performance Readout

The rollup lives in wip/client-performance-intermediate-report.md.

Headline current state:

  • Warmed query-plan cache vs recompilation: findUnique 752.61 -> 16.49 us/op, nested blog-page 3122.43 -> 37.16 us/op.
  • Plan-cache memory: blog-page retained heap about 18.75 MiB -> 4.48 MiB, about 76% lower; serialized retained plan JSON about 9.45 MiB -> 3.33 MiB, about 65% lower.
  • By-author blog-feed warmed generated path: generated default / request-precomputed / exact-helper 21.97 / 20.35 / 16.58 us/op -> 10.17 / 10.62 / 9.31 us/op; direct plan 13.70 -> 6.95 us/op.
  • Generated prepared by-author feed: around 7.82-8.06 us/op on Node versus recent exact-helper 9.20, and 6.70 us/op on Workerd versus exact-helper 8.10.
  • Flat string findFirst generated prepared helper: Node generated prepared 1.39 us/op versus default / exact-helper 2.49 / 2.37; Workerd request loop 1.45 us/op versus default / exact-helper 2.95 / 1.90.

The branch has strong partial wins, but it has not proven a uniform 3x improvement across every generated-client steady-state scenario yet. The strongest remaining leads are expanded generated prepared/exact cache-hit coverage, a static/generated final-owner schedule executor, JS-owned cache-hit/query-input architecture, and profile-backed Rust graph/translation ownership work.

Validation Already Run Locally

Latest harness-restart checkpoint:

  • pnpm --filter @prisma/client-generator-ts test buildExactDescriptorMatcherRegistry.test.ts: passed, 17 tests.
  • pnpm --filter @prisma/client-generator-js test buildExactDescriptorMatcherRegistry.test.ts: passed, 17 tests.
  • pnpm --filter @prisma/client-generator-ts build: passed outside sandbox for known tsx IPC restrictions.
  • pnpm --filter @prisma/client-generator-js build: passed outside sandbox for known tsx IPC restrictions.

Other accepted slices were validated with focused runtime tests, interpreter tests, local @prisma/client builds, Node timing probes, Miniflare/workerd timing and memory probes, and git diff --check.

Proposed Review Split

If this draft PR is too large as expected, split into a stack roughly like:

  1. Benchmark harness, persistent report, and cache/memory measurement infrastructure.
  2. Compact query-plan cache/runtime consumption and query-plan executor compatibility.
  3. Raw-nested runtime execution, relation ops, and final-owner schedule marker consumption.
  4. Generated exact descriptor helpers and generated prepared cache-hit helpers.
  5. Edge/Workerd call-surface improvements.

Internal data structures in this stack are version-lockstep. Internal format changes should replace producers and consumers together, without old/new compatibility branches unless a real external persistence or cross-version boundary exists.

tensordreams avatar Jun 24 '26 13:06 tensordreams

[!IMPORTANT]

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e37697d6-a2df-4dcb-9344-774528315c9d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch prisma-client-performance-2026-06-08
✨ Simplify code
  • [ ] Create PR with simplified code
  • [ ] Commit simplified code in branch prisma-client-performance-2026-06-08

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jun 24 '26 13:06 coderabbitai[bot]

🔴 CUSTOM ENGINE IS USED This PR is using custom engine:

Branch: prisma-client-performance-2026-06-08-engines Commit: 29000399a8a03aea36bbb263e0ddd46d10f24be9.

Don't forget to remove /engine-branch command from PR body and re-run the tests with default engine before merging.

github-actions[bot] avatar Jun 24 '26 14:06 github-actions[bot]