[PR #664] runtime: read PE files in blocks (RT-PE-BLOCK-READ) #704

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

📋 Pull Request Information

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

Base: main ← Head: perf/pe-block-reads


📝 Commits (2)

  • 291a96f runtime: read PE files in blocks (RT-PE-BLOCK-READ)
  • d8cfc01 tests: check whether the locked PE tail actually blocks CRT reads

📊 Changes

2 files changed (+63 additions, -4 deletions)

View changed files

📝 runtime/src/pe_loader.cpp (+12 -4)
📝 runtime/test/pe_loader_test.cpp (+51 -0)

📄 Description

Claimed in the coordination issue as RT-PE-BLOCK-READ. The block-read implementation and original Wine measurements come from cobrabm12's finding.

The loader reads PE files in 64 KiB blocks while retaining Windows wide paths and shared opening. It reports an I/O error instead of treating a failed read as EOF. The regression fixture locks a trailing range after a complete synthetic PE prefix. On the base, the loader mapped that prefix and failed two assertions. With the change it reports the read error, retains no partial module, and can load the same fixture after the lock is released.

Verification

  • Windows 11 26100.7623, MSVC 19.44 Release. The gta6rt target builds. loader, pe_loader, pe_loader_bounds, and pe_loader_fuzz pass (4/4). The PE loader fixture passes all 85 checks.
  • Warm, native --dry-run on the same synthetic PE padded to 120 MiB, six timed runs per build after warm-up. Median fell from 397.6 ms on 21625bc to 63.9 ms (6.22x). Both builds mapped two modules with zero unimplemented imports. This measures loading, mapping and binding the synthetic image.
  • Whitespace and game-data checks pass. GPU tests are not applicable to this I/O-only change.

AI-assisted implementation and verification.


🔄 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/664 **Author:** [@sodove](https://github.com/sodove) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/pe-block-reads` --- ### 📝 Commits (2) - [`291a96f`](https://github.com/ubiquitarianism/leonida/commit/291a96f7de73b66258ccf5380689b791e677c228) runtime: read PE files in blocks (RT-PE-BLOCK-READ) - [`d8cfc01`](https://github.com/ubiquitarianism/leonida/commit/d8cfc01d51998698c9f8d1c2bc3c17a45c388b55) tests: check whether the locked PE tail actually blocks CRT reads ### 📊 Changes **2 files changed** (+63 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/pe_loader.cpp` (+12 -4) 📝 `runtime/test/pe_loader_test.cpp` (+51 -0) </details> ### 📄 Description Claimed in the coordination issue as [RT-PE-BLOCK-READ](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7128772845). The block-read implementation and original Wine measurements come from [cobrabm12's finding](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127781668). The loader reads PE files in 64 KiB blocks while retaining Windows wide paths and shared opening. It reports an I/O error instead of treating a failed read as EOF. The regression fixture locks a trailing range after a complete synthetic PE prefix. On the base, the loader mapped that prefix and failed two assertions. With the change it reports the read error, retains no partial module, and can load the same fixture after the lock is released. ### Verification - Windows 11 26100.7623, MSVC 19.44 Release. The `gta6rt` target builds. `loader`, `pe_loader`, `pe_loader_bounds`, and `pe_loader_fuzz` pass (4/4). The PE loader fixture passes all 85 checks. - Warm, native `--dry-run` on the same synthetic PE padded to 120 MiB, six timed runs per build after warm-up. Median fell from 397.6 ms on `21625bc` to 63.9 ms (6.22x). Both builds mapped two modules with zero unimplemented imports. This measures loading, mapping and binding the synthetic image. - Whitespace and game-data checks pass. GPU tests are not applicable to this I/O-only change. AI-assisted implementation and verification. --- <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#704
No description provided.