Skip to content

Avoid temporary arrays when comparing JSON array values - #95

Merged
quinnj merged 1 commit into
masterfrom
maintenance/jsonschema-array-equality
Oct 4, 2026
Merged

quinnj merged 1 commit into
masterfrom
maintenance/jsonschema-array-equality

Conversation

@quinnj

@quinnj quinnj commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Array comparisons for const, enum, and uniqueItems build a Boolean array before testing whether every element matches. Nested arrays repeat that allocation at every level, and a mismatch at the first element still compares the entire array. Compare the existing recursive JSON equality function over zip instead, retaining the length check and stopping at the first difference.

The same JSON value rules are preserved: array order matters, equal numeric values compare equal, booleans remain distinct from numbers, and the existing nothing/missing null handling is unchanged. These follow Draft 7 instance equality.

Warmed median allocations for public validate calls on Julia 1.13.1/macOS ARM, excluding input/schema construction:

Input Before After
const, 100,000 equal integers 12,928 bytes 32 bytes
const, 100,000 integers with first item different 13,072 bytes 176 bytes
enum, first candidate is 100,000 equal integers 12,928 bytes 32 bytes
const, 10,000 nested arrays of four integers 961,456 bytes 32 bytes
const, 10 equal integers 128 bytes 32 bytes

These are local medians over eleven warmed samples. Fully equal flat 100,000-item arrays were slower in these runs (about 17 to 28 microseconds); early differences and nested comparisons were faster. This prioritizes bounded allocations and short-circuiting and does not claim a uniform throughput improvement.

Validation: all 5,642 checks pass on actual Julia 1.9.4 and 1.13.1 with four threads and bounds checking, including 4,492 official corpus checks and 162 new controls for equality symmetry, empty/unequal arrays, views, nested objects/nulls/booleans, failure paths/pointers, and successful/early-failing allocation growth. The unchanged current base passes 160 controls and fails the two allocation guards. JuliaFormatter 2.14.0's read-only check passes. An independent agent privately reviewed the final source/tests and found no blocker. No API, export, dependency, or version changes.

Hosted validation at bf69159df7c478b9be06e14f49461776eda40840: all six Julia 1.10/current jobs on Linux, macOS, and Windows, plus formatting, pass. All six coverage uploads were accepted for this repository and commit and processed at 96.25%; the stable Linux log confirms strict OIDC upload success.

Post-merge validation at 4982236495a50af33bd7dd413a39d6c36facf40a: all six native jobs and formatting pass. All six coverage reports were accepted and processed for the merge commit at 96.25%. The fetched merge tree matches the tested tree.

Co-authored by Codex

AI disclosure: This work was prepared with assistance from OpenAI Codex.

Compare elements lazily with the existing recursive JSON equality rules.
Keep the length check and stop at the first differing value. Cover const,
enum, uniqueItems, nested values, views, issue paths, and allocation growth.

AI disclosure: This work was prepared with assistance from OpenAI Codex.
@quinnj
quinnj merged commit 4982236 into master Oct 4, 2026
7 checks passed
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