[PR #115] runtime: unified loader/OS perf pack (console paths, per-DLL import cache, SHA-NI, lock-free registry) #166

Open
opened 2026-11-26 20:17:00 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/115
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9849


📝 Commits (5)

  • 0886b92 file_system: parse console paths without copying the path or the roots
  • 3af273d pe_loader: probe the game folder and load the host DLL once per imported DLL, not once per import
  • a676e12 pe_loader: only cache successful bundled/host probes so failed probes remain retryable
  • 7bffe8e runtime: sha256_hex hashes in place, unrolled, with the x86 SHA extensions (4.6-7.0x)
  • f41a8ff registry: an unimplemented import's repeat call takes no lock and does no lookup

📊 Changes

12 files changed (+1792 additions, -109 deletions)

View changed files

📝 runtime/CMakeLists.txt (+27 -0)
📝 runtime/shims/file_system.cpp (+60 -34)
📝 runtime/shims/registry.cpp (+25 -26)
➕ runtime/shims/unimplemented_import.h (+32 -0)
➕ runtime/src/lazy.h (+41 -0)
📝 runtime/src/pe_loader.cpp (+51 -9)
📝 runtime/src/pe_loader.h (+3 -0)
📝 runtime/src/shader_library.h (+157 -40)
➕ runtime/test/file_system_parse_test.cpp (+208 -0)
➕ runtime/test/pe_loader_import_cache_test.cpp (+611 -0)
➕ runtime/test/sha256_hex_test.cpp (+251 -0)
➕ runtime/test/unimplemented_import_test.cpp (+326 -0)

📄 Description

Carried over from old PR 9849 by TG0000 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9849, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
TG0000: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Consolidated C++ runtime startup, path-parsing, SHA-256, and lock-free unimplemented-import performance pack replacing closed PRs #8045, #8340, #8358, and #8439 (all previously independently verified on Windows MSVC, Linux GCC + ASan/UBSan, and real executable loading).

What this combines

  1. Zero-copy console path parsing (was #8045): cuts allocations (7 -> 1 on G:, 11 -> 3 on T:) and -84% CPU; preserves win32_io_path() long-path handling on main.
  2. Per-DLL import probe & host DLL load cache (was #8340): probes game dir and loads host DLL once per imported DLL instead of once per import (~36x faster, 725 -> 12 exists/LoadLibraryExA calls), caching only successful non-null probes (rt::Lazy::get_if_truthy) so failed probes stay retryable; preserves resolve_compat on main.
  3. In-place unrolled sha256_hex with x86 SHA-NI (was #8358): 4.6x–7.0x faster (237 -> 33.9 us on 64 KiB) with portable fallback.
  4. Lock-free repeat unimplemented import calls (was #8439): no mutex or map lookup on repeat calls (51x–81x faster).

Testing

  • Compiled with clang++ (-std=c++20 -O2 -Wall -Wextra -Werror, 0 new warnings) on Windows 11 (Ryzen 9 5900X):
    • CTest (-DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF): shader_library, sha256_hex (x86 SHA extensions path), and unimplemented_import (81.0x speedup) — 3/3 pass.
    • pe_loader_import_cache_test --reps 3: ok (2,000 random tables + dynamic retry case, 36.47x speedup).
    • file_system_parse_test: 272/272 checks pass.
  • git diff --check and scripts/check_no_game_data.py clean. No game data used.

AI-assisted (Claude Opus 5.5).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/115 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9849` --- ### 📝 Commits (5) - [`0886b92`](https://github.com/ubiquitarianism/leonida/commit/0886b92068adf410c57661a559f844f23c299bbe) file_system: parse console paths without copying the path or the roots - [`3af273d`](https://github.com/ubiquitarianism/leonida/commit/3af273dcccfd217fc4367e9dbc4cd7c2e6f74aed) pe_loader: probe the game folder and load the host DLL once per imported DLL, not once per import - [`a676e12`](https://github.com/ubiquitarianism/leonida/commit/a676e125c0d7a5342e5e52557699c4d933e06bd9) pe_loader: only cache successful bundled/host probes so failed probes remain retryable - [`7bffe8e`](https://github.com/ubiquitarianism/leonida/commit/7bffe8edba97eb563441ea73129477036b86aa04) runtime: sha256_hex hashes in place, unrolled, with the x86 SHA extensions (4.6-7.0x) - [`f41a8ff`](https://github.com/ubiquitarianism/leonida/commit/f41a8ff28347081c23f6bff91922e76bf285a6e2) registry: an unimplemented import's repeat call takes no lock and does no lookup ### 📊 Changes **12 files changed** (+1792 additions, -109 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+27 -0) 📝 `runtime/shims/file_system.cpp` (+60 -34) 📝 `runtime/shims/registry.cpp` (+25 -26) ➕ `runtime/shims/unimplemented_import.h` (+32 -0) ➕ `runtime/src/lazy.h` (+41 -0) 📝 `runtime/src/pe_loader.cpp` (+51 -9) 📝 `runtime/src/pe_loader.h` (+3 -0) 📝 `runtime/src/shader_library.h` (+157 -40) ➕ `runtime/test/file_system_parse_test.cpp` (+208 -0) ➕ `runtime/test/pe_loader_import_cache_test.cpp` (+611 -0) ➕ `runtime/test/sha256_hex_test.cpp` (+251 -0) ➕ `runtime/test/unimplemented_import_test.cpp` (+326 -0) </details> ### 📄 Description > Carried over from **old PR 9849** by `TG0000` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9849`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `TG0000`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Consolidated C++ runtime startup, path-parsing, SHA-256, and lock-free unimplemented-import performance pack replacing closed PRs `#8045`, `#8340`, `#8358`, and `#8439` (all previously independently verified on Windows MSVC, Linux GCC + ASan/UBSan, and real executable loading). ### What this combines 1. **Zero-copy console path parsing** (was `#8045`): cuts allocations (`7 -> 1` on `G:`, `11 -> 3` on `T:`) and `-84%` CPU; preserves `win32_io_path()` long-path handling on `main`. 2. **Per-DLL import probe & host DLL load cache** (was `#8340`): probes game dir and loads host DLL once per imported DLL instead of once per import (`~36x` faster, `725 -> 12` `exists`/`LoadLibraryExA` calls), caching only successful non-null probes (`rt::Lazy::get_if_truthy`) so failed probes stay retryable; preserves `resolve_compat` on `main`. 3. **In-place unrolled `sha256_hex` with x86 SHA-NI** (was `#8358`): `4.6x–7.0x` faster (`237 -> 33.9 us` on 64 KiB) with portable fallback. 4. **Lock-free repeat unimplemented import calls** (was `#8439`): no mutex or map lookup on repeat calls (`51x–81x` faster). ### Testing - Compiled with clang++ (`-std=c++20 -O2 -Wall -Wextra -Werror`, 0 new warnings) on Windows 11 (Ryzen 9 5900X): - CTest (`-DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF`): `shader_library`, `sha256_hex` (x86 SHA extensions path), and `unimplemented_import` (81.0x speedup) — 3/3 pass. - `pe_loader_import_cache_test --reps 3`: ok (2,000 random tables + dynamic retry case, 36.47x speedup). - `file_system_parse_test`: 272/272 checks pass. - `git diff --check` and `scripts/check_no_game_data.py` clean. No game data used. AI-assisted (Claude Opus 5.5). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#166
No description provided.