Skip to content

Conversation

tobias-tengler
Copy link
Member

@tobias-tengler tobias-tengler commented Oct 17, 2025

  • Adds benchmarks for OperationCompiler, DocumentRewriter and the plan portion of OperationPlanner.
  • Removes DocumentRewriter from OperationCompiler for improved performance
    • We have already rewritten the document when compiling and the DocumentRewriter is basically just sorting the inserted requirements at that point...

@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 16:08
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 OperationCompiler performance by removing the InlineFragmentOperationRewriter and refactoring method signatures to work directly with operations instead of full documents.

Key changes:

  • Removes InlineFragmentOperationRewriter from OperationCompiler since documents are already rewritten when compiling
  • Changes DocumentRewriter.RewriteDocument to return OperationDefinitionNode directly via RewriteOperation
  • Adds benchmarks for OperationCompiler, DocumentRewriter, and OperationPlanner

Reviewed Changes

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

Show a summary per file
File Description
DocumentRewriter.cs Changed method signature to return OperationDefinitionNode directly and improved field comparison logic
OperationCompiler.cs Removed InlineFragmentOperationRewriter dependency and redundant document rewriting
OperationPlanner.cs Added TryCreatePlan method and improved selection inlining with deduplication
Various test files Updated method calls to use new RewriteOperation signature
Benchmark files Added new benchmark classes for performance testing

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

Comment on lines 1392 to 1407
if (seenSelections.Add(fieldWithDirective))
{
var insertIndex = newSelections.Count;
var fieldName = field.Name.Value;

for (var i = newSelections.Count - 1; i >= 0; i--)
{
if (newSelections[i] is FieldNode existingField
&& existingField.Name.Value.Equals(fieldName, StringComparison.Ordinal))
{
insertIndex = i + 1;
break;
}
}

newSelections.Insert(insertIndex, fieldWithDirective);
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

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

The reverse loop to find insertion index could be inefficient for large selection sets. Consider maintaining a dictionary mapping field names to their last index positions to avoid O(n) lookups for each insertion.

Copilot uses AI. Check for mistakes.

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.

1 participant