Skip to content

Remove uniqueItems from blockStates schema - #1259

Merged
rom1504 merged 1 commit into
PrismarineJS:masterfrom
u9g:remove-blockstates-uniqueitems
Aug 27, 2026
Merged

Remove uniqueItems from blockStates schema#1259
rom1504 merged 1 commit into
PrismarineJS:masterfrom
u9g:remove-blockstates-uniqueitems

Conversation

@u9g

@u9g u9g commented Aug 27, 2026

Copy link
Copy Markdown
Member

Problem

npm test takes ~9 minutes. ~425s of that is the 29 blockStates.json is valid tests (12–36s each).

The cause is "uniqueItems": true on the top-level array in blockStates_schema.json. Ajv 6 implements uniqueItems for 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:

time
uniqueItems: true 71,316 ms
uniqueItems: false 11 ms

Change

  • Drop uniqueItems from 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).
  • Remove the 180s per-test timeout bump in test.js that 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.

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.
@rom1504
rom1504 merged commit fc3f709 into PrismarineJS:master Aug 27, 2026
4 checks passed
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.
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.

2 participants