Skip to content

fix: avoid deep-hashing the response subtree during reference extraction#9820

Closed
sethrperkins wants to merge 1 commit into
apollographql:devfrom
sethrperkins:fix-extended-reference-hashing
Closed

fix: avoid deep-hashing the response subtree during reference extraction#9820
sethrperkins wants to merge 1 commit into
apollographql:devfrom
sethrperkins:fix-extended-reference-hashing

Conversation

@sethrperkins

Copy link
Copy Markdown

extract_enums_from_selection_set dedupes visited fragment spreads with a
HashSet<(&str, &Object)>. Hashing &Object hashes the pointed-to value, so
every fragment spread deep-hashes the whole response subtree. With
metrics_reference_mode: extended, extraction cost scales with response size
times fragment-spread count, and operations with many fragments over large
responses regress noticeably.

Keying on the object's pointer (*const Object) dedupes on identity, which is
all this needs, and restores O(1) insertion.

Introduced in #9473.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

  • Documentation, metrics, and logs: no impact. This is an internal fix with no configuration or behavior change.
  • Tests: the existing apollo_studio_interop unit tests exercise fragment-spread deduplication and pass unchanged. The change only swaps the dedup key from value to identity and preserves output, so no new test was added.

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@apollo-cla

Copy link
Copy Markdown

@sethrperkins: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@apollo-librarian

apollo-librarian Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@sethrperkins
sethrperkins force-pushed the fix-extended-reference-hashing branch from 9118a4c to c87a963 Compare July 16, 2026 19:28
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