Skip to content

shader_library: move nested JSON values during parsing - #1108

Open
Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:perf/json-subtree-moves-continued
Open

Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:perf/json-subtree-moves-continued

Conversation

@Kadamitas

@Kadamitas Kadamitas commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-JSON-SUBTREE-MOVES (claim)

What and why

The explicitly defaulted destructor suppresses the implicit move constructor of Json. Passing a parsed child to a vector with std::move therefore copies its strings and nested vectors. Growing an object or array can copy those subtrees again. Letting the compiler generate the destructor restores nonthrowing moves for both Json and JsonObjectEntry. The forward declaration still supports recursive object values.

Tested

  • shader_library_test and mods_test passed under MSVC x64, GCC 11.4 and Clang 18.1.8 with libstdc++. Clang 15 with libstdc++ 11 rejects the existing C++20 aggregate construction in emplace_back on both revisions.

  • A synthetic input had 1,200 named entries, each with a label and four arrays of six small objects. Both builds produced 181,201 nodes and the same tree digest from the 1,141,381-byte document. Five interleaved release runs per revision under MSVC gave median parse times of 71.14 ms before and 17.46 ms after. Allocation counts fell from 822,984 to 176,419. File reads and digest calculation were outside the timed region.

  • git diff --check and scripts/check_no_game_data.py runtime/src/shader_library.h passed.

  • The general translator suite ran 6,168 tests across 470 files with zero failing files.

GPUs tested: n/a, CPU-only JSON parsing.

AI-assisted: yes, Codex.

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • Translator rule documentation is inapplicable to this parser change.

@abnalstlll-byte abnalstlll-byte 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.

Audited and verified. Removing the user-declared destructor allows the compiler to generate implicit move constructors and move assignment operators for Json, enabling std::vector reallocations and parser insertions to move subtrees instead of deep-copying. Clean-room compliant. Approved.

@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

Recommendation: [MERGE]

Reasoning: Removes Json's explicitly defaulted destructor so the implicit noexcept move constructor comes back, avoiding deep copies of parsed subtrees. One-line performance change with no behaviour change; shader_library_test and mods_test pass per the author. No new test, but none is really needed. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 2/10

@Kadamitas
Kadamitas force-pushed the perf/json-subtree-moves-continued branch from f6ea7b6 to 269971a Compare November 27, 2026 18:56
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.

3 participants