Skip to content

perf(query-compiler): Prisma Client performance groundwork#5820

Draft
tensordreams wants to merge 113 commits into
mainfrom
prisma-client-performance-2026-06-08-engines
Draft

perf(query-compiler): Prisma Client performance groundwork#5820
tensordreams wants to merge 113 commits into
mainfrom
prisma-client-performance-2026-06-08-engines

Conversation

@tensordreams

@tensordreams tensordreams commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Draft status PR for the engines side of the ongoing Prisma Client performance work. This branch contains query-compiler, query-plan serialization, raw-nested read, and compile-path allocation changes that the sibling Prisma branch consumes.

This is intentionally not merge-ready as a final review unit. The branch is currently large (113 commits ahead, 1 commit behind fresh main) because it accumulated accepted experiments and measurement infrastructure during the performance 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 Prisma PR: prisma/prisma#29655

Extracted child PRs:

Current split plan: wip/client-performance-pr-stack.md in the sibling Prisma PR branch.

Linked Prisma branch for CI

The engines workflow reads this command from the PR body and builds Prisma adapters/client code from the sibling branch:

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

The reciprocal Prisma PR uses /engine-branch prisma-client-performance-2026-06-08-engines so Prisma CI builds this engines branch.

Main Contents

  • Compact and allocation-focused query-plan serialization work.
  • Query-compiler graph/translation allocation reductions backed by allocation probes and Criterion checks.
  • Raw-nested relation-op emission for pagination/distinct cases, including M:N mapped operation fields and one-to-many parent grouping.
  • Raw-nested final-owner schedule marker emission for the Prisma runtime to consume.
  • Quaint/Postgres INSERT ... SELECT ... RETURNING and insert-in-CTE prerequisites for a future M:N connect phase-owner, while the direct CTE phase-owner prototype itself stayed reverted.
  • Focused benchmark fixtures and allocation-profile infrastructure used by the investigation.

Current Performance Readout

See the sibling Prisma report for the cross-repo rollup: wip/client-performance-intermediate-report.md on prisma-client-performance-2026-06-08.

Important engine-side examples from the journal:

  • FK-backed required to-one nested update child-read shortcut: update-set-nested-prisma#27650 full-compile allocations 1621 -> 1453, Criterion about 153.20 -> 135.75 us.
  • Raw-nested one-to-many relation-op path: nested-distinct-pagination-query full-compile allocations 726 -> 627, Criterion about 75.20 -> 65.90 us.
  • M:N mapped relation-op path: query-m2m-pagination-mapped-distinct full-compile allocations 1519 -> 942, Criterion about 134.37 -> 83.23 us.
  • M:N set parent-key delete work: update-m2m-set-empty 1547 -> 1208 and update-m2m-set 1922 -> 1586 full-compile allocations.
  • Nested-only upsert shared read: upsert-nested-only-update full-compile allocations 1835 -> 1475, with focused Criterion around 187.37 -> 149.31 us.

Validation Already Run Locally

Representative accepted slices were validated with combinations of:

  • cargo check -p query-compiler
  • cargo test -p query-compiler --test queries
  • focused allocation-profile runs against the named query-compiler fixtures
  • focused Criterion patched/control checks for target rows and sampled controls
  • make build-qc-wasm for runtime-consuming query-compiler changes

The latest Prisma-side harness restart revalidated the generated prepared-helper slice against this branch context; see the sibling PR for exact pnpm commands.

Proposed Review Split

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

  1. Quaint insert-select / insert-CTE prerequisites for future M:N connect work. Extracted as perf(quaint): support insert-select CTEs #5821.
  2. Parser/request allocation reductions. Extracted as perf(query-compiler): reduce parser request allocations #5822.
  3. Compact internal plan serialization plus allocation/profile infrastructure.
  4. Compiler-local graph/translation allocation reductions.
  5. Raw-nested read plans.
  6. Write graph pruning.
  7. Raw-nested relation ops and final-owner schedule marker emission.

Internal formats in this stack are lockstep-only. There should not be old/new compatibility readers unless a real external persistence boundary is identified.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Add a return-preserving flow node for exactly-one nested noop update upserts so the nested write can run while the branch still returns the parent row to a shared final read. This removes the duplicated raw nested read from upsert-nested-only-update.

Allocation profile: upsert-nested-only-update full_compile allocs 1835 -> 1475 and bytes 214.4 KiB -> 177.7 KiB; sampled controls unchanged.

Criterion: target improved 187.37 -> 149.31 us, repeat 185.21 -> 146.76 us. Focused upsert controls showed only small local noise.
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

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: 866375e4-71c1-4459-9ca1-52432254022d

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-engines
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch prisma-client-performance-2026-06-08-engines

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.

@codspeed-hq

codspeed-hq Bot commented Jun 24, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 17.88%

⚡ 4 improved benchmarks
✅ 7 untouched benchmarks
⏩ 11 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
mutation 6.4 ms 4.3 ms +50.27%
medium_read 314.8 µs 283.6 µs +10.99%
small_read 105.4 µs 96.1 µs +9.71%
large_read 1.6 ms 1.5 ms +5.53%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing prisma-client-performance-2026-06-08-engines (2900039) with main (1171e96)

Open in CodSpeed

Footnotes

  1. 11 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

Copy link
Copy Markdown
Contributor

Wasm Query Compiler File Size

Engine This PR Base branch Diff
Postgres 3.572MiB 3.508MiB 65.550KiB
Postgres (gzip) 1.176MiB 1.143MiB 33.960KiB
Postgres (size-optimized) 1.784MiB 1.767MiB 17.359KiB
Postgres (size-optimized, gzip) 706.881KiB 695.609KiB 11.273KiB
Mysql 3.523MiB 3.461MiB 63.509KiB
Mysql (gzip) 1.162MiB 1.128MiB 34.998KiB
Mysql (size-optimized) 1.754MiB 1.737MiB 17.185KiB
Mysql (size-optimized, gzip) 696.199KiB 684.340KiB 11.859KiB
Sqlite 3.436MiB 3.378MiB 58.699KiB
Sqlite (gzip) 1.130MiB 1.099MiB 31.758KiB
Sqlite (size-optimized) 1.710MiB 1.693MiB 17.649KiB
Sqlite (size-optimized, gzip) 678.929KiB 667.397KiB 11.533KiB
SQL Server 3.667MiB 3.596MiB 73.183KiB
SQL Server (gzip) 1.195MiB 1.161MiB 35.387KiB
SQL Server (size-optimized) 1.784MiB 1.766MiB 18.746KiB
SQL Server (size-optimized, gzip) 710.535KiB 698.450KiB 12.085KiB
CockroachDB 3.622MiB 3.558MiB 65.498KiB
CockroachDB (gzip) 1.194MiB 1.162MiB 33.094KiB
CockroachDB (size-optimized) 1.810MiB 1.792MiB 18.544KiB
CockroachDB (size-optimized, gzip) 717.590KiB 705.558KiB 12.033KiB

@CLAassistant

CLAassistant commented Jun 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aqrln aqrln changed the title [codex] perf(query-compiler): Prisma Client performance groundwork perf(query-compiler): Prisma Client performance groundwork Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants