Skip to content

Fix fragment field-merging validation and reduce allocations - #3085

Open
ghostdogpr wants to merge 1 commit into
series/3.xfrom
codex/fix-fragment-field-merging
Open

Fix fragment field-merging validation and reduce allocations#3085
ghostdogpr wants to merge 1 commit into
series/3.xfrom
codex/fix-fragment-field-merging

Conversation

@ghostdogpr

@ghostdogpr ghostdogpr commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • preserve named-fragment identity while collecting fields instead of recursively inlining fragment spreads
  • compare nested selections using both return types and the correct overlapping or mutually-exclusive mode
  • memoize fragment-name pairs and field-map/fragment pairs with constant-size keys
  • stop on the first conflict instead of accumulating error chunks
  • add same-object and different-object nested response-shape regression coverage plus an 80-fragment DAG benchmark

Previously, nested fields with the same response name but incompatible leaf types could pass validation beneath mutually-exclusive fragments. Recursing with only the first field type also dropped child fields when the two return object types differed. The validator now resolves and compares both sides independently, while retaining fragment names for O(1) pair memoization.

Benchmarks

Like-for-like JMH runs on JDK 25: 2 forks, 5 one-second warmups, 8 two-second measurement iterations per fork, with GC profiling. Scores show throughput with the JMH 99.9% confidence interval.

Benchmark series/3.x This PR Throughput impact Allocation impact
80-fragment DAG 396.2 ± 5.8 ops/s 715.0 ± 14.2 ops/s +80.5% / 1.80x 5.83 → 2.81 MB/op, -51.8%
Existing fragment conflicts 40.67k ± 0.53k ops/s 105.19k ± 2.13k ops/s +158.7% / 2.59x 68.08 → 38.03 KB/op, -44.1%
FragmentsQueryBenchmark 97.28 ± 1.90 ops/s 106.87 ± 1.98 ops/s +9.9% / 1.10x 81.39 → 4.26 MB/op, -94.8%

Verification

  • sbt fmt
  • core test: 623 tests passed
  • MiMa passed on Scala 2.12, 2.13, and 3.3
  • regression tests cover incompatible nested leaf types beneath both identical and different return object types

@ghostdogpr ghostdogpr changed the title Optimize fragment field-merging validation Fix nested fragment field merging and reduce validation allocations Aug 6, 2026
@ghostdogpr
ghostdogpr force-pushed the codex/fix-fragment-field-merging branch from 516fe8a to 3af64e9 Compare August 6, 2026 09:05
@ghostdogpr ghostdogpr changed the title Fix nested fragment field merging and reduce validation allocations Fix fragment field-merging validation and reduce allocations Aug 6, 2026
@ghostdogpr
ghostdogpr force-pushed the codex/fix-fragment-field-merging branch from 3af64e9 to 4812873 Compare August 6, 2026 09:10
@ghostdogpr
ghostdogpr marked this pull request as ready for review August 6, 2026 09:11
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