Skip to content

perf(query-compiler): reduce parser request allocations#5822

Draft
tensordreams wants to merge 9 commits into
mainfrom
prisma-client-perf-parser-request-allocs
Draft

perf(query-compiler): reduce parser request allocations#5822
tensordreams wants to merge 9 commits into
mainfrom
prisma-client-perf-parser-request-allocs

Conversation

@tensordreams

Copy link
Copy Markdown
Contributor

Summary

Second split-out draft from the large Prisma Client performance branch.

This PR keeps the parser/request-handler allocation reductions that are local to query request parsing and JSON protocol adaptation:

  • reduce query parser argument cloning
  • avoid input object schema map allocation
  • avoid parsed argument value cloning
  • avoid eager argument conversion error construction
  • avoid empty exclusion vector allocation
  • use mutable query parser paths
  • use SmallVec for parser validation paths
  • collect selection exclusions inline in the JSON protocol adapter
  • consume singleton parsed values instead of cloning them

Relation To Larger Work

Parent status PR: #5820

Prior extracted PR: #5821

This branch is independent of the sibling Prisma runtime branch and does not need /prisma-branch.

Scope

Changed files:

  • query-compiler/core/src/query_document/parse_ast.rs
  • query-compiler/core/src/query_document/parser.rs
  • query-compiler/request-handlers/src/protocols/json/body.rs
  • query-compiler/request-handlers/src/protocols/json/protocol_adapter.rs

This PR intentionally does not include compact query-plan format changes, raw-nested read plans, or write-graph pruning.

Validation

  • cargo check -p query-core: passed
  • cargo check -p request-handlers: passed
  • cargo check -p query-compiler: passed
  • CARGO_TARGET_DIR=/home/aqrln.guest/prisma/.tmp/parser-request-target cargo test -p query-compiler --test queries: passed

The explicit CARGO_TARGET_DIR avoids the local /tmp quota that was hit during the first test attempt.

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: 6b372454-76da-4079-a425-3a1c047a764e

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-perf-parser-request-allocs
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch prisma-client-perf-parser-request-allocs

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.

@CLAassistant

CLAassistant commented Jun 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codspeed-hq

codspeed-hq Bot commented Jun 24, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 55.28%

⚡ 1 improved benchmark
✅ 10 untouched benchmarks
⏩ 11 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
mutation 6.4 ms 4.1 ms +55.28%

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-perf-parser-request-allocs (32132b2) 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.493MiB 3.508MiB -15.334KiB
Postgres (gzip) 1.140MiB 1.143MiB -2.925KiB
Postgres (size-optimized) 1.761MiB 1.767MiB -6.524KiB
Postgres (size-optimized, gzip) 692.976KiB 695.612KiB -2.636KiB
Mysql 3.446MiB 3.461MiB -15.277KiB
Mysql (gzip) 1.124MiB 1.128MiB -4.108KiB
Mysql (size-optimized) 1.731MiB 1.737MiB -6.579KiB
Mysql (size-optimized, gzip) 681.330KiB 684.340KiB -3.011KiB
Sqlite 3.364MiB 3.378MiB -15.153KiB
Sqlite (gzip) 1.096MiB 1.099MiB -3.567KiB
Sqlite (size-optimized) 1.687MiB 1.693MiB -6.586KiB
Sqlite (size-optimized, gzip) 664.913KiB 667.394KiB -2.482KiB
SQL Server 3.581MiB 3.596MiB -15.347KiB
SQL Server (gzip) 1.157MiB 1.161MiB -3.465KiB
SQL Server (size-optimized) 1.760MiB 1.766MiB -6.590KiB
SQL Server (size-optimized, gzip) 695.424KiB 698.453KiB -3.029KiB
CockroachDB 3.543MiB 3.558MiB -15.344KiB
CockroachDB (gzip) 1.158MiB 1.162MiB -4.012KiB
CockroachDB (size-optimized) 1.786MiB 1.792MiB -6.536KiB
CockroachDB (size-optimized, gzip) 702.429KiB 705.562KiB -3.133KiB

@aqrln aqrln changed the title [codex] perf(query-compiler): reduce parser request allocations perf(query-compiler): reduce parser request allocations 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