Skip to content

perf(spec): batch Ajv validations in validate.py - #2467

Open
jacobsimionato wants to merge 2 commits into
a2ui-project:mainfrom
jacobsimionato:perf-batch-spec-validate
Open

perf(spec): batch Ajv validations in validate.py#2467
jacobsimionato wants to merge 2 commits into
a2ui-project:mainfrom
jacobsimionato:perf-batch-spec-validate

Conversation

@jacobsimionato

Copy link
Copy Markdown
Collaborator

Overview

This PR optimizes the specification validation script (specification/scripts/validate.py) by batching Ajv schema validations.

Key Changes:

  • Batched Ajv Subprocess Calls: Instead of spawning a separate node / ajv process for each of the 110+ example JSON files individually (~400ms per invocation), validate_messages() now batches all example message files for a given spec version into a single run_ajv() call.
  • Performance Gains: Reduces total execution time of python3 specification/scripts/validate.py from ~45 seconds down to ~3 seconds (a 14x speedup).

Verification

  • Ran python3 specification/scripts/validate.py across all test suites (v0.8, v0.9, v1.0).
  • Confirmed output reports Overall Validation: PASSED in 3.1s.

Batch all example data paths into a single Ajv CLI invocation per spec version instead of spawning Node/Ajv subprocesses 110+ times in a loop. Reduces overall specification validation time from ~45s to ~3s.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the validate_messages function in specification/scripts/validate.py to batch the validation of all example messages into a single run_ajv invocation, improving performance. It also updates the error handling to return immediately on JSON decoding or validation failures. There are no review comments, so no additional feedback is provided.

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