Skip to content

Index TypeUtils schema name lookups - #965

Merged
iuliiasobolevska merged 1 commit into
masterfrom
perf/index-typeutils-name-lookups
Sep 23, 2026
Merged

iuliiasobolevska merged 1 commit into
masterfrom
perf/index-typeutils-name-lookups

Conversation

@iuliiasobolevska

Copy link
Copy Markdown
Collaborator

Summary

Replace the remaining per-field schema scans in Java TypeUtils with lookups against the document-scoped SchemaIndex.

The indexed lookups cover:

  • object and interface detection for wildcard list return types
  • enum, union, and interface detection when generating interface return types
  • object and enum detection when schema definitions shadow built-in common scalar mappings

The public TypeUtils constructor that accepts a Document remains unchanged.

Relationship to #962

#962 introduced SchemaIndex, built its document-order-preserving definitionsByName map once, and shared that index through the generator graph.
Its PR description explicitly left the residual per-field scans in TypeUtils for a separate optimization.

This PR is that follow-up.
It preserves #962's definitionsByName implementation and adds type-kind predicates that inspect only definitions(name), reusing the existing map instead of scanning every document definition or building a competing index.

Performance

The real ot-occommon-dgs consumer benchmark at commit 8ce1311d generated 9,015 files and measured:

Revision Median Range
Current master (7100dae0) 2.33 s 2.29–2.59 s
This PR 2.236 s 2.180–2.313 s

The nominal median improvement is 4.0%.
Because the ranges overlap, this is directional evidence rather than a claim of a stable 4% speedup.

Every run produced the same 41,058,296 bytes across the same 9,015 paths with complete-tree SHA-256 cb765785686ac0f9d6c709cbc00ab3d635899e5932e5db361cd56fbc195132f3.

Correctness safeguards

  • Preserve wildcard resolution when schemas contain both Foo and IFoo.
  • Preserve interface, enum, and union return-type behavior.
  • Preserve schema-defined Date and PageInfo shadowing of built-in mappings.
  • Preserve Index schema model lookups during code generation #962's same-name and document-order lookup semantics.

Verification

  • ./gradlew :graphql-dgs-codegen-core:test :graphql-dgs-codegen-core:integTest :graphql-dgs-codegen-core:lintKotlinMain :graphql-dgs-codegen-core:lintKotlinTest --no-scan
  • Real-consumer benchmark with byte-identical generated output

@iuliiasobolevska
iuliiasobolevska merged commit e91a69d into master Sep 23, 2026
2 checks passed
@iuliiasobolevska
iuliiasobolevska deleted the perf/index-typeutils-name-lookups branch September 23, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants