HLE: find an import's implementation by name, not by scanning every module #141
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!141
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/141/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TG0000 on GitHub · 2026-11-24 00:54 UTC · original
TG0000:perf/hle-import-index→main· +320 −6 · 1 files · 1 commits · closed without mergingWhat
registry::lookupbinds every title import we implement and servesGetProcAddresson host modules (host_override). For each call it walked all modules, and each module'sserveslower-cased the DLL name into a newStringbefore testing its patterns. Then it compared the name against every export of the serving modules. A miss paid the full cost, and every import we leave to the host is a miss.The registry is now indexed once, by export name, in registry order, keeping the first export of a name in each module. A lookup:
The result doesn't change: the first serving module in registry order wins, and within it the first export with that name.
HleModule::servesand the other callers are untouched, and onlycrates/victory-hle/src/registry.rschanges.Numbers
Release build, one core. The benchmark looks up every registry export under each DLL name that serves it (upper-cased, API sets with a version suffix), plus one host-only miss per DLL name. That's 605 lookups, best of 5, over 3 runs:
To run it:
cargo test --release -p victory-hle registry_lookup_throughput -- --ignored --nocaptureTests
matchesagrees withHleModule::serveson mixed-case, non-ASCII, empty and prefix-boundary names.Checked with:
cargo test --workspace --exclude victory-gpu: all pass.cargo clippy -p victory-hle --all-targets: no warnings in the touched file.cargo xtask policy: OK.cargo fmt --checkon the file: clean.victory-gpu's tests don't build on currentmain(9aef3d9):crates/victory-gpu/src/host.rsdefinesmod teststwice (lines 252 and 1974). This PR doesn't touch that crate, so I left it out of the workspace run.Doesn't overlap any open PR.
This PR is AI-assisted (Claude). It was tested on Windows 11 with the MSVC stable toolchain, using unit tests and a synthetic release benchmark. No game data is involved and nothing needed a GPU.
🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-24 04:33 UTC · original
Tested head
2f6efc1933109d4aa5e6ad4320edb8bc63086683withcargo test -p victory-hle --lib registry -- --test-threads=1: 7 passed, 0 failed, 1 ignored (the ignored case is a benchmark; 84 unrelated tests were filtered out). Coverage includes indexed lookup agreeing with a full scan, preserving module/export order, case-insensitive patterns, and first-serving-module precedence (registry.rs). This is unit coverage; title import resolution was not exercised in a runtime.Pull request closed