shader_library: move nested JSON values during parsing #1108

Open
github-bot wants to merge 1 commit from github-bot/gh-1108 into main AGit
Owner

@⁠Kadamitas on GitHub · 2026-11-24 18:38 UTC · original
Kadamitas:perf/json-subtree-moves-continued → main · +1 −6 · 1 files · 1 commits · open

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.
**@⁠Kadamitas** on GitHub · 2026-11-24 18:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1108) `Kadamitas:perf/json-subtree-moves-continued` → `main` · +1 −6 · 1 files · 1 commits · open Claimed in the coordination issue as: RT-JSON-SUBTREE-MOVES ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)) ### 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 - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] Translator rule documentation is inapplicable to this parser change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:38:37 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:38 UTC · original · approved these changes

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.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1108#pullrequestreview-6045185688) · **approved these changes** 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.
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:17 UTC · original

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

**@⁠Deedlyy** on GitHub · 2026-11-24 20:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1108#issuecomment-7143305612) **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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1108/head:github-bot/gh-1108'
git switch 'github-bot/gh-1108'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1108'
git switch 'github-bot/gh-1108'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1108'
git switch 'github-bot/gh-1108'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1108'
git switch 'main'
git merge --squash 'github-bot/gh-1108'
git switch 'main'
git merge --ff-only 'github-bot/gh-1108'
git switch 'main'
git merge 'github-bot/gh-1108'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.