Skip to content

bluejay-validator performance optimizations#96

Open
swalkinshaw wants to merge 1 commit intomainfrom
validator-perf-optimizations
Open

bluejay-validator performance optimizations#96
swalkinshaw wants to merge 1 commit intomainfrom
validator-perf-optimizations

Conversation

@swalkinshaw
Copy link
Contributor

Reduce validator allocation overhead — ~28% faster on representative queries

Optimizations:

  • Replace HashSet/HashMap with Vec + linear scan in hot paths where N is small (parent_fragments, cycle detection, required arguments, argument equivalence, type overlap checks)
  • Eliminate Path Vec allocation by making Path Copy
  • Optimize duplicates() to skip BTreeMap allocation when no duplicates found (common case), and avoid intermediate (K,T) vec
  • Reuse Cache's fragment_definitions HashMap in FragmentSpreadTargetDefined instead of building a separate HashSet
  • Collect errors via &mut Vec in FieldSelectionMerging instead of returning intermediate Vecs

Also adds a criterion benchmark suite for the validation pipeline.

Note: this is a manually curated (with the help of Claude) and cleaned up version of an /autoresearch run

…queries

Optimizations:

- Replace HashSet/HashMap with Vec + linear scan in hot paths where N
  is small (parent_fragments, cycle detection, required arguments,
  argument equivalence, type overlap checks)
- Eliminate Path Vec allocation by making Path Copy
- Optimize duplicates() to skip BTreeMap allocation when no duplicates
  found (common case), and avoid intermediate (K,T) vec
- Reuse Cache's fragment_definitions HashMap in FragmentSpreadTargetDefined
  instead of building a separate HashSet
- Collect errors via &mut Vec in FieldSelectionMerging instead of
  returning intermediate Vecs

Also adds a criterion benchmark suite for the validation pipeline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@swalkinshaw swalkinshaw requested a review from adampetro March 17, 2026 18:15
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