Repository navigation
Conversation
|
@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 is really interesting. I think we here at I wonder if we could try to provide an execution arg for passing a function that creates the empty record object in the manner of our users' choosing? would that extra function cause too much overhead? If this would work, it would allow the graphql tools executor to eventually migrate back to graphql-js if they so choose without losing this performance win. @benjie I know we discusses previously the importance of null prototypes => an advanced option such as the above would also presumably allow users to forgo null prototypes at their peril, although of course, that would have to be done on purpose. Thanks again! |
|
Just highlighting that in my own testing, that this optimization for Node/Deno (V8) is a regression for Bun (JavaScriptCore). This argues strongly in favor of allowing this to be configurable, although we could set the default to V8... |
Summary
Dense execution results allocate a null-prototype map for each completed object. Use a shared empty constructor before removing the prototype at the two hot allocation sites:
Results remain fresh, mutable, null-prototype objects. Tests cover synchronous/asynchronous completion, prototype-like aliases, descriptors and independent results. Request-setup maps and serial mutation execution are unchanged. This uses the same allocation approach as GraphQL Tools #8610.
Evidence
Actual source patch versus
c93662d, Node 24.22.1 / Windows x64, five fresh paired processes, identical 100 MB responses:Idle heap is approximately 13.7 MB; input-ready heap is 219.3 MB on both sides. Input remains live. Heap is sampled at phase checkpoints; RSS includes process startup. No mid-execution GC or profiler. This is a dense small-object workload, not a universal memory claim.
The 25 MB pilot improves added heap by 55.40%, but execution alone is 9.40% slower. The promise-heavy 3 MB case improves added heap by only 7.83% and RSS by 4.01%. Timing varies; every 100 MB pair improves the tabled metrics.
An additional 40 paired trials cover 1/8/32/100-field objects on Node and Bun. Node's retained-output saving is about 79% for 1/8 fields, but essentially zero for 32/100 fields; 32-field execution is 5.56% slower. Bun 1.3.14 shows no consistent memory benefit: 8-field execution is 3.36% slower and 32-field RSS is 5.36% higher. These are workload/engine tradeoffs for review, with short, variable timings; full matrix and methodology.
Reproduction scripts, protocol and raw paired results are kept outside this PR's diff.
Validation on Linux/Node 24.19.0: 3,112 source tests with 100% line/branch/function coverage, 360 examples, 11 fuzz tests, repository lint/types/formatting/spelling, npm/Deno builds and the Deno package check all pass. The new regression cases also pass on Bun 1.3.14.
The unchanged integration harness passes 17 cases; 12 fail at unavailable Docker launches. All 15 subsequent direct Node/Bun/Deno commands pass using Node 24.19.0 and the repository's pinned Bun 1.2.18 / Deno 2.4.1. Full container/version-matrix checks remain for CI. The earlier Windows Deno-path/CRLF issues pass in the clean Linux checkout. Validation details and logs.
Merge Danger
Door: two-way.
Blast Radius: execution.
No intended observable result change. The memory benefit depends on engine object layout and result shape; the wider-object and Bun tradeoffs above need maintainer assessment before merge.