Skip to content

Conversation

pavelnikolov
Copy link
Member

  • Group fields by response key to cut overlap comparisons (addresses Control memory explosion on large list of queries #102).
  • Add identical-field shallow+hash fast path (k >= 3) with per-op hash cache.
  • Add benchmarks and a //go:build bench tag to conditionally build benchmarks.
  • Minor refactors: simplify allIdenticalFields & shallowFieldEqual.

@pavelnikolov pavelnikolov requested a review from Copilot August 23, 2025 19:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes overlap validation in GraphQL queries by implementing performance improvements to reduce O(n²) comparison complexity. The optimization focuses on grouping fields by response key and adding a fast path for structurally identical fields.

  • Groups fields by response key to avoid unnecessary overlap comparisons between fields with different aliases
  • Adds an identical-field fast path with structural hashing for groups of 3+ fields
  • Includes comprehensive benchmarks to measure performance improvements

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/validation/validation.go Core optimization implementation with field grouping, hash-based identical field detection, and structural comparison functions
internal/validation/pathological_overlap_bench_test.go Benchmark testing pathological overlap scenarios with alternating field definitions
fragment_queries_bench_test.go Comprehensive benchmarks for fragment queries and alias scenarios to measure validation performance
Comments suppressed due to low confidence (1)

fragment_queries_bench_test.go:55

  • The b.Loop() method does not exist in the standard testing package. This should be for i := 0; i < b.N; i++ or use for range b.N in Go 1.22+.
}

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pavelnikolov pavelnikolov force-pushed the prevent-memory-explosion branch from e4a9c7c to d010c9b Compare August 24, 2025 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