Remove uniqueItems from blockStates schema - #1259
Merged
Merged
Conversation
Ajv 6 checks uniqueItems on object arrays with a pairwise deep-equal loop, which is O(n^2). blockStates.json files have ~17k entries, so each of the 29 bedrock versions took 12-36s to validate (~425s of a ~9min CI run); the same file validates in ~11ms without it. Uniqueness of generated block state entries is not an invariant we rely on.
u9g
added a commit
to u9g/minecraft-data
that referenced
this pull request
Aug 30, 2026
The suite used to take ~3min, almost all of it in protodef-validator < 1.5.0 (quadratic dataType validation, PrismarineJS#1259 removed the other hotspot, Ajv's uniqueItems). Require 1.5.0 and assert total suite wall-clock stays under 40s (~20s locally) so a regression shows up in CI.
rom1504
pushed a commit
that referenced
this pull request
Aug 30, 2026
The suite used to take ~3min, almost all of it in protodef-validator < 1.5.0 (quadratic dataType validation, #1259 removed the other hotspot, Ajv's uniqueItems). Require 1.5.0 and assert total suite wall-clock stays under 40s (~20s locally) so a regression shows up in CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm testtakes ~9 minutes. ~425s of that is the 29blockStates.json is validtests (12–36s each).The cause is
"uniqueItems": trueon the top-level array inblockStates_schema.json. Ajv 6 implementsuniqueItemsfor object items with a pairwise deep-equal loop, so with ~17k entries per file it does ~140M comparisons.Measured on
bedrock/1.26.30/blockStates.json(16,913 entries) with ajv 6.15.0:uniqueItems: trueuniqueItems: falseChange
uniqueItemsfrom the schema. The data is generated and uniqueness of state entries isn't an invariant anything relies on (I checked all 29 distinct files: 0 duplicates).test.jsthat was added to accommodate this.Expected effect: CI drops from ~10 min to ~2 min. The remaining time is dominated by
protocol.json is valid, which is fixed upstream in ProtoDef-io/node-protodef-validator#18 and just needs a release + bump.