Skip to content

perf: backport compact execution result maps to v16 - #4922

Draft
jhonDoe15 wants to merge 1 commit into
graphql:16.x.xfrom
jhonDoe15:perf/compact-execution-results-v16
Draft

jhonDoe15 wants to merge 1 commit into
graphql:16.x.xfrom
jhonDoe15:perf/compact-execution-results-v16

Conversation

@jhonDoe15

Copy link
Copy Markdown

Summary

Candidate 16.x backport of #4919, targeting the next appropriate 16.x release if maintainers accept the allocation tradeoff. The original v17 PR is still under review; this draft preserves a separately validated backport without implying prior approval.

- Object.create(null)
+ Object.setPrototypeOf(new CompactExecutionResultMap(), null)

Ports the two result-map allocations to execution/execute.ts and jsutils/promiseForObject.ts. Results stay fresh, mutable and null-prototype. The regression tests are adapted to 16.x's Mocha/formatting conventions. No version bump, Node requirement, public API or dependency change. Four files, +85/-2 lines.

Evidence

Actual npm builds against 6944e23, Linux/WSL2, Node 20.19.5; five fresh paired 100 MB dense-response trials with identical bytes/hash:

Metric Base median Backport median Median paired reduction
Request-added heap 1,210.78 MB 612.84 MB 49.38%
Peak RSS 1,495.65 MB 924.03 MB 39.71%
Execution elapsed 7.96 s 6.87 s 11.66%
Execution + serialization/encoding/hash 9.91 s 8.13 s 19.26%

Idle heap is approximately 6.2 MB and input-ready heap 211.9 MB on both sides. Input stays live; heap checkpoints are not continuous peaks, and RSS includes startup. All five pairs improve the tabled metrics. The promise-heavy 3 MB case saves only 14.09% added heap.

Limits: wide Node objects have essentially no retained-output memory saving, and Bun 1.2.18 has no consistent substantial memory benefit. The initial 100-field Node case is 9.03% slower overall; a separate larger five-pair confirmation is 0.13% slower. Bun's 32/100-field cases are 5.10%/6.44% slower overall. These regressions and timing variability remain relevant to stable-release acceptance.

Validation: 2,014 tests pass on both Node 12.22.12 and 20.19.5; lint, types, full formatting, spelling, npm/Deno builds and fuzz tests pass. Built CommonJS/ESM result-map checks pass on both runtimes. TypeScript and Webpack integration projects pass; the Node-container project is blocked by unavailable Docker, while its test program passes directly on both runtimes. c8 produces an empty report on both base and candidate, so coverage is not claimed. The full CI runtime/container matrix remains outstanding.

Reproduction scripts, paired raw results and validation logs remain outside this PR's diff.

Merge Danger

Door: two-way.

Blast Radius: execution.

No intended observable result change. The optimization depends on engine object layout and result shape. Please assess the approach in #4919 and the 16.x-specific evidence before accepting it for the stable line; maintainers control release timing and version.

@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@jhonDoe15 is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant