Skip to content

perf(graphql): reuse filtered variables across resolve spans#9225

Merged
tlhunter merged 2 commits into
masterfrom
BridgeAR/2026-07-06-perf-graphql-resolve-variables
Jul 14, 2026
Merged

perf(graphql): reuse filtered variables across resolve spans#9225
tlhunter merged 2 commits into
masterfrom
BridgeAR/2026-07-06-perf-graphql-resolve-variables

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

The graphql.resolve variable tags run the user-supplied config.variables filter once for every instrumented field that carries arguments, even though graphql coerces variableValues once per execute and hands the same object to every resolver. Caching the filtered result on the execute context runs the filter once per operation instead.

Why

The reduction (once-per-argument-bearing-field to once-per-execute) is structural and safe by inspection: the same filter runs against the same coerced variableValues object, so the produced tags are identical. Draft until I run a microbenchmark on a representative deep query to confirm the win is worth keeping.

@dd-octo-sts

dd-octo-sts Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.63 MB
Deduped: 7.29 MB
No deduping: 7.29 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 437.94 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@BridgeAR
BridgeAR marked this pull request as ready for review July 6, 2026 19:06
@BridgeAR
BridgeAR requested a review from a team as a code owner July 6, 2026 19:06
@BridgeAR
BridgeAR requested review from tlhunter and removed request for a team July 6, 2026 19:06
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jul 6, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 96.50% (+8.91%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c6dbf6a | Docs | Datadog PR Page | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26eec4e180

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/datadog-plugin-graphql/src/execute.js Outdated
@pr-commenter

pr-commenter Bot commented Jul 6, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-07 20:50:13

Comparing candidate commit c6dbf6a in PR branch BridgeAR/2026-07-06-perf-graphql-resolve-variables with baseline commit f3dba8a in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2248 metrics, 38 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-182.806ms; +186.296ms] or [-6.930%; +7.062%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-206.256ms; +198.070ms] or [-8.229%; +7.902%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-155149.018µs; +153454.884µs] or [-5.397%; +5.338%]

scenario:appsec-control-20

  • unstable execution_time [-111.598ms; +109.573ms] or [-6.861%; +6.737%]

scenario:appsec-control-24

  • unstable execution_time [-102.855ms; +105.878ms] or [-8.469%; +8.718%]

scenario:appsec-control-26

  • unstable execution_time [-110911.261µs; +109335.228µs] or [-9.197%; +9.066%]

scenario:debugger-line-probe-with-snapshot-default-24

  • unstable cpu_user_time [-2246.276ms; +380.136ms] or [-25.243%; +4.272%]
  • unstable execution_time [-2243.037ms; +383.829ms] or [-23.397%; +4.004%]
  • unstable instructions [-19.1G instructions; +3.2G instructions] or [-26.211%; +4.331%]
  • unstable throughput [-131.706op/s; +642.777op/s] or [-3.810%; +18.593%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable cpu_user_time [-1747.531ms; +626.524ms] or [-18.646%; +6.685%]
  • unstable execution_time [-1758.760ms; +630.465ms] or [-17.440%; +6.252%]
  • unstable instructions [-15.9G instructions; +5.7G instructions] or [-20.392%; +7.280%]
  • unstable throughput [-148.338op/s; +380.063op/s] or [-4.559%; +11.681%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-1667.209ms; +2525.677ms] or [-19.505%; +29.548%]
  • unstable execution_time [-1692.670ms; +2563.836ms] or [-18.343%; +27.784%]
  • unstable instructions [-14.0G instructions; +21.4G instructions] or [-20.025%; +30.627%]
  • unstable max_rss_usage [-7.565MB; +10.055MB] or [-4.829%; +6.418%]
  • unstable throughput [-711.845op/s; +486.387op/s] or [-20.096%; +13.731%]

scenario:debugger-line-probe-with-snapshot-minimal-26

  • unstable cpu_user_time [-2122.009ms; +3344.779ms] or [-22.602%; +35.625%]
  • unstable execution_time [-2145.130ms; +3379.765ms] or [-21.320%; +33.590%]
  • unstable instructions [-18.5G instructions; +29.5G instructions] or [-23.636%; +37.751%]
  • unstable max_rss_usage [-7.134MB; +9.925MB] or [-4.496%; +6.254%]
  • unstable throughput [-731.831op/s; +467.552op/s] or [-22.418%; +14.322%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-1160.390ms; +2891.269ms] or [-14.021%; +34.936%]
  • unstable execution_time [-1166.578ms; +2911.506ms] or [-13.033%; +32.528%]
  • unstable instructions [-9.8G instructions; +24.7G instructions] or [-14.650%; +36.685%]
  • unstable max_rss_usage [-6.937MB; +9.149MB] or [-4.408%; +5.814%]
  • unstable throughput [-882.545op/s; +255.735op/s] or [-24.053%; +6.970%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-1919.133ms; +576.283ms] or [-20.536%; +6.167%]
  • unstable execution_time [-1940.629ms; +562.618ms] or [-19.317%; +5.600%]
  • unstable instructions [-19.3G instructions; +5.5G instructions] or [-24.740%; +7.026%]
  • unstable throughput [-119.015op/s; +439.294op/s] or [-3.636%; +13.422%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-347.287ms; +359.366ms] or [-7.108%; +7.355%]
  • unstable execution_time [-346.813ms; +360.346ms] or [-6.991%; +7.264%]
  • unstable throughput [-124111.555op/s; +117792.109op/s] or [-7.329%; +6.956%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-7.591MB; +5.248MB] or [-5.928%; +4.099%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-4171.058KB; +4029.058KB] or [-5.257%; +5.078%]

@BridgeAR
BridgeAR marked this pull request as draft July 6, 2026 19:16
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.53%. Comparing base (f3dba8a) to head (c6dbf6a).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9225      +/-   ##
==========================================
+ Coverage   93.56%   96.53%   +2.97%     
==========================================
  Files         900      911      +11     
  Lines       52690   120348   +67658     
  Branches    12411    20719    +8308     
==========================================
+ Hits        49300   116183   +66883     
- Misses       3390     4165     +775     
Flag Coverage Δ
aiguard 53.57% <ø> (+18.52%) ⬆️
aiguard-integration 57.39% <ø> (+15.43%) ⬆️
apm-bucket-0 53.79% <ø> (+18.92%) ⬆️
apm-bucket-1 58.10% <ø> (+17.45%) ⬆️
apm-bucket-2 56.12% <ø> (+18.84%) ⬆️
apm-capabilities-tracing 60.51% <51.61%> (+11.56%) ⬆️
apm-integrations-aerospike 52.94% <ø> (+19.75%) ⬆️
apm-integrations-confluentinc-kafka-javascript 57.07% <ø> (+16.89%) ⬆️
apm-integrations-couchbase 53.27% <ø> (+19.80%) ⬆️
apm-integrations-http 57.98% <ø> (+15.88%) ⬆️
apm-integrations-kafkajs 57.72% <ø> (+17.36%) ⬆️
apm-integrations-next 54.24% <ø> (+24.55%) ⬆️
apm-integrations-prisma 54.20% <ø> (+18.96%) ⬆️
apm-integrations-tedious 53.04% <ø> (?)
appsec 69.04% <ø> (+11.10%) ⬆️
appsec-express_fastify_graphql 65.68% <64.51%> (+11.75%) ⬆️
appsec-integration 45.53% <64.51%> (+9.93%) ⬆️
appsec-kafka_ldapjs_lodash 59.13% <ø> (+15.32%) ⬆️
appsec-mongodb-core_mongoose_mysql 62.32% <ø> (+13.38%) ⬆️
appsec-next 52.86% <ø> (+24.75%) ⬆️
appsec-node-serialize_passport_postgres 61.92% <ø> (+13.79%) ⬆️
appsec-sourcing_stripe_template 60.27% <ø> (+14.59%) ⬆️
debugger 65.69% <ø> (+21.08%) ⬆️
instrumentations-bucket-0 48.77% <ø> (+20.54%) ⬆️
instrumentations-bucket-1 54.97% <ø> (+17.31%) ⬆️
instrumentations-bucket-10 56.65% <ø> (+16.08%) ⬆️
instrumentations-bucket-11 48.73% <ø> (+20.70%) ⬆️
instrumentations-bucket-12 48.84% <ø> (+19.98%) ⬆️
instrumentations-bucket-13 48.67% <ø> (+20.81%) ⬆️
instrumentations-bucket-2 49.73% <ø> (+19.31%) ⬆️
instrumentations-bucket-3 53.84% <ø> (+17.71%) ⬆️
instrumentations-bucket-4 49.16% <ø> (+20.49%) ⬆️
instrumentations-bucket-5 53.01% <ø> (+16.54%) ⬆️
instrumentations-bucket-6 55.62% <ø> (+17.14%) ⬆️
instrumentations-bucket-7 53.61% <ø> (+17.41%) ⬆️
instrumentations-bucket-8 54.65% <ø> (+17.48%) ⬆️
instrumentations-bucket-9 56.10% <ø> (+16.44%) ⬆️
instrumentations-instrumentation-couchbase 48.16% <ø> (+1.68%) ⬆️
instrumentations-integration-esbuild 33.94% <ø> (+9.46%) ⬆️
llmobs-ai_anthropic_bedrock 57.28% <ø> (+17.55%) ⬆️
llmobs-bucket-1 56.81% <ø> (?)
llmobs-google-genai_langchain_vertex-ai ?
llmobs-openai 57.58% <ø> (+17.79%) ⬆️
llmobs-sdk 59.99% <ø> (+16.34%) ⬆️
llmobs-vertex-ai 54.22% <ø> (?)
master-coverage 96.53% <100.00%> (?)
openfeature 54.61% <ø> (+16.68%) ⬆️
openfeature-unit 49.82% <ø> (-0.66%) ⬇️
platform-core_esbuild_instrumentations-misc 38.41% <ø> (+15.49%) ⬆️
platform-integration 62.19% <ø> (+14.62%) ⬆️
platform-shimmer_unit-guardrails_webpack 37.21% <ø> (+18.77%) ⬆️
plugins-bucket-0 53.18% <ø> (+16.61%) ⬆️
plugins-bucket-1 55.08% <ø> (+15.31%) ⬆️
plugins-bucket-11 56.74% <ø> (+18.05%) ⬆️
plugins-bucket-17 56.76% <ø> (+17.48%) ⬆️
plugins-bucket-18 57.57% <51.61%> (+15.34%) ⬆️
plugins-bucket-19 57.13% <100.00%> (+17.10%) ⬆️
plugins-bucket-20 59.39% <ø> (+15.90%) ⬆️
plugins-bucket-4 53.86% <ø> (+15.90%) ⬆️
plugins-bullmq_cassandra_cookie 57.41% <ø> (+17.42%) ⬆️
plugins-cookie-parser_crypto_dd-trace-api 52.32% <ø> (+19.03%) ⬆️
plugins-fetch_fs_generic-pool 54.47% <ø> (+18.20%) ⬆️
plugins-google-cloud-pubsub_grpc_handlebars 59.89% <ø> (+16.74%) ⬆️
plugins-hapi_hono_ioredis 55.87% <ø> (+17.87%) ⬆️
plugins-jest_knex_langgraph 51.66% <ø> (+18.99%) ⬆️
plugins-ldapjs_light-my-request_limitd-client 53.42% <ø> (+25.43%) ⬆️
plugins-lodash_mariadb_memcached 54.21% <ø> (+18.97%) ⬆️
plugins-mongodb_mongodb-core_mongoose 55.13% <ø> (+18.61%) ⬆️
plugins-multer_mysql_mysql2 54.38% <ø> (+19.16%) ⬆️
plugins-nats_node-serialize_opensearch 56.07% <ø> (+18.70%) ⬆️
plugins-passport-http_pino_postgres 54.75% <ø> (+19.16%) ⬆️
plugins-process_pug_redis 53.87% <ø> (+19.54%) ⬆️
plugins-undici_url_valkey 54.38% <ø> (+18.29%) ⬆️
plugins-vm_winston_ws 55.28% <ø> (+17.50%) ⬆️
profiling 58.21% <ø> (+14.33%) ⬆️
serverless-aws-sdk-aws-sdk 50.66% <ø> (+17.29%) ⬆️
serverless-aws-sdk-bedrockruntime 50.68% <ø> (+18.43%) ⬆️
serverless-aws-sdk-client 51.96% <ø> (+14.79%) ⬆️
serverless-aws-sdk-dynamodb 51.75% <ø> (+17.48%) ⬆️
serverless-aws-sdk-eventbridge 46.21% <ø> (+18.79%) ⬆️
serverless-aws-sdk-kinesis 54.71% <ø> (+17.10%) ⬆️
serverless-aws-sdk-lambda 52.78% <ø> (+18.09%) ⬆️
serverless-aws-sdk-s3 51.52% <ø> (+18.83%) ⬆️
serverless-aws-sdk-serverless-peer-service 54.73% <ø> (+15.02%) ⬆️
serverless-aws-sdk-sns 55.48% <ø> (+16.91%) ⬆️
serverless-aws-sdk-sqs 55.91% <ø> (+17.71%) ⬆️
serverless-aws-sdk-stepfunctions 51.25% <ø> (+17.97%) ⬆️
serverless-aws-sdk-util 48.45% <ø> (+0.50%) ⬆️
serverless-bucket-0 55.24% <ø> (+15.61%) ⬆️
serverless-bucket-1 56.02% <ø> (?)
serverless-lambda ?
test-optimization-cucumber 73.01% <ø> (+20.72%) ⬆️
test-optimization-cypress 66.51% <ø> (+16.53%) ⬆️
test-optimization-jest 73.97% <ø> (+18.47%) ⬆️
test-optimization-mocha 74.34% <ø> (+20.95%) ⬆️
test-optimization-playwright-playwright-atr 61.67% <ø> (+18.33%) ⬆️
test-optimization-playwright-playwright-efd 61.85% <ø> (+18.24%) ⬆️
test-optimization-playwright-playwright-final-status 61.79% <ø> (+18.05%) ⬆️
test-optimization-playwright-playwright-impacted-tests 61.53% <ø> (+18.28%) ⬆️
test-optimization-playwright-playwright-reporting 61.60% <ø> (+18.32%) ⬆️
test-optimization-playwright-playwright-test-management 62.35% <ø> (+17.51%) ⬆️
test-optimization-playwright-playwright-test-span 61.58% <ø> (+17.05%) ⬆️
test-optimization-selenium 60.69% <ø> (+15.36%) ⬆️
test-optimization-testopt 59.15% <ø> (+12.50%) ⬆️
test-optimization-vitest 72.83% <ø> (+20.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-07-06-perf-graphql-resolve-variables branch from 4a06136 to b225685 Compare July 7, 2026 01:32
The graphql.resolve variable tags ran the user-supplied config.variables
filter once for every instrumented field that carries arguments, even though
graphql coerces variableValues once per execute and hands the same object to
every resolver. Memoize the filtered result against the last-seen
variableValues object so the filter runs once per operation.

The cache is a single { key, value } slot compared by identity, not a WeakMap.
graphql hands every resolver in one execute the same variableValues object, so
the common case is a bare `===` hit with no per-operation allocation. A nested
execute() sharing the same object contextValue reuses the outer rootCtx but
carries its own variableValues; the identity compare recomputes for it and the
later inner fields reuse the slot, so each field's tags stay correct. A
regression test covers that nested case.

Microbenchmark (Node v26.3.1, V8 14.6, n=2M x 7 trials, drop best+worst),
per-operation cost of rootCtx setup + N arg-bearing field filters:

  1 field,  1 object:  baseline  53 ns  weakmap 73 ns (+37%)  slot 54 ns (+2%)
  3 fields, 1 object:  baseline 163 ns  weakmap 82 ns (-49%)  slot 56 ns (-65%)
  10 fields,1 object:  baseline 519 ns  weakmap 113 ns(-78%)  slot 61 ns (-88%)
  3 fields, 2 objects: baseline 160 ns  weakmap 147 ns(-8%)   slot 114 ns(-29%)
  10 fields,2 objects: baseline 506 ns  weakmap 177 ns(-65%)  slot 124 ns(-75%)

A WeakMap regresses the single-field common case (its allocation costs more
than one filter call); the identity slot wins in every scenario.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-07-06-perf-graphql-resolve-variables branch from b225685 to febfaad Compare July 7, 2026 11:57
@BridgeAR
BridgeAR marked this pull request as ready for review July 7, 2026 12:12
…fields

A single operation selecting two argument-bearing fields is the only shape that
reaches the cached return in #filterVariables; every prior variables test picks
one field and only ever hits the miss path. Assert both sibling resolve spans
draw their own tags from the one shared filtered object and that the filter runs
once for the resolve path rather than per field.
@tlhunter
tlhunter merged commit 9c965cc into master Jul 14, 2026
653 checks passed
@tlhunter
tlhunter deleted the BridgeAR/2026-07-06-perf-graphql-resolve-variables branch July 14, 2026 17:04
This was referenced Jul 15, 2026
juan-fernandez pushed a commit that referenced this pull request Jul 16, 2026
* perf(graphql): reuse filtered variables across resolve spans

The graphql.resolve variable tags ran the user-supplied config.variables
filter once for every instrumented field that carries arguments, even though
graphql coerces variableValues once per execute and hands the same object to
every resolver. Memoize the filtered result against the last-seen
variableValues object so the filter runs once per operation.

The cache is a single { key, value } slot compared by identity, not a WeakMap.
graphql hands every resolver in one execute the same variableValues object, so
the common case is a bare `===` hit with no per-operation allocation. A nested
execute() sharing the same object contextValue reuses the outer rootCtx but
carries its own variableValues; the identity compare recomputes for it and the
later inner fields reuse the slot, so each field's tags stay correct. A
regression test covers that nested case.

Microbenchmark (Node v26.3.1, V8 14.6, n=2M x 7 trials, drop best+worst),
per-operation cost of rootCtx setup + N arg-bearing field filters:

  1 field,  1 object:  baseline  53 ns  weakmap 73 ns (+37%)  slot 54 ns (+2%)
  3 fields, 1 object:  baseline 163 ns  weakmap 82 ns (-49%)  slot 56 ns (-65%)
  10 fields,1 object:  baseline 519 ns  weakmap 113 ns(-78%)  slot 61 ns (-88%)
  3 fields, 2 objects: baseline 160 ns  weakmap 147 ns(-8%)   slot 114 ns(-29%)
  10 fields,2 objects: baseline 506 ns  weakmap 177 ns(-65%)  slot 124 ns(-75%)

A WeakMap regresses the single-field common case (its allocation costs more
than one filter call); the identity slot wins in every scenario.

* test(graphql): exercise the memoized variables filter across sibling fields

A single operation selecting two argument-bearing fields is the only shape that
reaches the cached return in #filterVariables; every prior variables test picks
one field and only ever hits the miss path. Assert both sibling resolve spans
draw their own tags from the one shared filtered object and that the filter runs
once for the resolve path rather than per field.
juan-fernandez pushed a commit that referenced this pull request Jul 16, 2026
* perf(graphql): reuse filtered variables across resolve spans

The graphql.resolve variable tags ran the user-supplied config.variables
filter once for every instrumented field that carries arguments, even though
graphql coerces variableValues once per execute and hands the same object to
every resolver. Memoize the filtered result against the last-seen
variableValues object so the filter runs once per operation.

The cache is a single { key, value } slot compared by identity, not a WeakMap.
graphql hands every resolver in one execute the same variableValues object, so
the common case is a bare `===` hit with no per-operation allocation. A nested
execute() sharing the same object contextValue reuses the outer rootCtx but
carries its own variableValues; the identity compare recomputes for it and the
later inner fields reuse the slot, so each field's tags stay correct. A
regression test covers that nested case.

Microbenchmark (Node v26.3.1, V8 14.6, n=2M x 7 trials, drop best+worst),
per-operation cost of rootCtx setup + N arg-bearing field filters:

  1 field,  1 object:  baseline  53 ns  weakmap 73 ns (+37%)  slot 54 ns (+2%)
  3 fields, 1 object:  baseline 163 ns  weakmap 82 ns (-49%)  slot 56 ns (-65%)
  10 fields,1 object:  baseline 519 ns  weakmap 113 ns(-78%)  slot 61 ns (-88%)
  3 fields, 2 objects: baseline 160 ns  weakmap 147 ns(-8%)   slot 114 ns(-29%)
  10 fields,2 objects: baseline 506 ns  weakmap 177 ns(-65%)  slot 124 ns(-75%)

A WeakMap regresses the single-field common case (its allocation costs more
than one filter call); the identity slot wins in every scenario.

* test(graphql): exercise the memoized variables filter across sibling fields

A single operation selecting two argument-bearing fields is the only shape that
reaches the cached return in #filterVariables; every prior variables test picks
one field and only ever hits the miss path. Assert both sibling resolve spans
draw their own tags from the one shared filtered object and that the filter runs
once for the resolve path rather than per field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants