Loader: add O(1) envelope fast-reject, packed RangeEntry lookup, and synchronized registration in modules #2673
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2673
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2673"
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?
@Decodere on GitHub · 2026-11-26 05:45 UTC · original
Decodere:fix-modules-range-table-fast-reject-and-sync→main· +212 −24 · 1 files · 1 commits · openWhat is in it
Improves lock-free module address lookup performance, fixes high-address overflow bugs, and eliminates a registration/unregistration race in
crates/xcl/src/modules.rs:RangeEntrytable (RangeTable): Replaced splitRANGE_BASE/RANGE_SIZE/RANGE_COUNTstatics with a self-containedRangeTablepacking#[repr(C)] struct RangeEntry { base: AtomicUsize, size: AtomicUsize }per slot and maintaining a monotonic[min_addr, max_inclusive]envelope. Out-of-envelope probes (such as PC D3D12/driver callers in0x7ff...during guarded COM calls or VEH dispatch) reject in O(1) without scanning all registered slots, and in-envelope scans only loadsizewhenb != 0 && addr >= b.register_mappedandunregister_mappednow mutateRANGESstrictly while holdingMAPPED.write(), preventing concurrentunregister_mappedcalls from missing an in-flightregister_mappedslot and leaving zombie entries. WhenMAX_RANGES(512) is reached,RangeTable::insertclampscountand signals a one-timexlog_warn!logged strictly after droppingMAPPED.write().addr < self.base + self.sizeinMappedModule::containswithaddr.checked_sub(self.base).is_some_and(|off| off < self.size), and replacedaddr < b + sinRangeTable::lookupwithaddr - b < s(afteraddr >= b) andbase.saturating_add(size - 1)formax_inclusive, avoiding debug overflow panics and release wraparound nearusize::MAX.describe_address,MAIN, and existing tests untouched.Part of #1833
Tested
origin/main(b49be183,cargo test -p xcl --lib "modules::tests::" -- --test-threads=1 --nocapture):2 passed; 1 failed; 0 ignored—contains_handles_base_plus_size_overflowpanicked atmodules.rs:34:37(attempt to add with overflow).XCL_ADAPTER=warp,XCL_WARP=1,cargo test -p xcl --lib "modules::tests::" -- --test-threads=1 --nocapture):4 passed; 0 failed; 0 ignored; 0 skipped(0.00s, zero compiler warnings inmodules.rs).XCL_ADAPTER=warp,XCL_WARP=1,cargo test --release -p xcl --lib "modules::tests::" -- --test-threads=1 --nocapture):4 passed; 0 failed; 0 ignored; 0 skipped(0.00s).0x7FF9_1234_5678lookups against 32 registered modules on an isolatedRangeTable):14.11 ns->0.73 ns(19.3xfaster, WARP run) /16.02 ns->0.71 ns(22.6xfaster, RTX run).cargo clippy --all-targets):0new warnings incrates/xcl/src/modules.rs(only 1 pre-existingunusual_byte_groupingslint on untouched test literal0x1000_0000_4).cargo test --release -p xcl --lib "modules::tests::" -- --test-threads=1 --nocapture):4 passed; 0 failed; 0 ignored; 0 skipped(0.01s).Regression run
Full release workspace on RTX 4060 (
cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture):37test binaries,1437 passed; 0 failed; 47 ignored,29pre-existing environment-gatedSKIPPEDlines:21skipped:no wave64(RTX 4060 is wave32)3skipped: wave32per-lane form: refusedby driver (f16 arithmetic,f16 packed,f32 conversions)3skipped: no D3D12 debug layer (d3d12SDKLayers.dllunavailable on host: debug-layerdred: false/trueanduploads_start_from_each_subresources_state)1skipped:pso_measurement_compiles_an_exact_synthetic_record(cannot disable driver cache on Windows)1skipped:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Paired 60 s RTX 4060 smoke capture (
scripts/smoke.ps1):Base (
origin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7):PR (
8660a4593d51dfbf26abf9a41580d3e896ef1bb2):Not tested
512modules (saturation behavior is verified on an isolatedRangeTable::new()instance to avoid polluting the process-wide table).29host-gated workspace tests skipped on this RTX 4060 machine (wave64 hardware, wave32 per-lane driver support, D3D12 SDK debug layer, driver cache disable, and heap windows).AI use
Google Antigravity (Gemini 4 Neon) wrote the patch, unit tests, and PR description; all commands, test runs, micro-benchmarks, and paired 60 s GPU smoke captures were executed directly in this workspace.
@luckyteagirl on GitHub · 2026-11-26 05:47 UTC · original · reviewed
Could the concurrency test drive overlapping registration and unregistration of the same base? Its writers own disjoint addresses, and each completes
register_mappedbefore its ownunregister_mapped, so it cannot exercise the split publication race this patch fixes. On main, a registration can publishRANGE_BASE, a concurrent same-base unregister can clear it beforeMAPPED.push, and registration can then leavefind_mapped_by_basepopulated whileimage_base_for_addrreturnsNone. A controlled same-base interleaving with an assertion that both lookups agree after the threads finish would catch that regression. Source-based review at exact head8660a4593d51dfbf26abf9a41580d3e896ef1bb2; no runtime race test was run. AI-assisted review with Codex.@SlopTart on GitHub · 2026-11-26 06:50 UTC · original · edited 2026-11-26 07:02 UTC
Tested on the Linux/Wine lane, full standard env (AMD rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB, Arch kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 Proton, rustc 1.94.0;
d3d12,d3d12core,dxgi,d3d11,d3d10core=n,boverrides, official DXC kit,VKD3D_CONFIG=ignore_shared_fence, threads=2), head8660a459, mergeable against mainb49be183:non-gpu suite (
--skip gpu::): 598 passed, 3 failed, 4 ignored, 733 filtered.The failure set is identical to bare main
b49be183measured on the same rig the same day (596 passed, 3 failed): gpu_promoted_uav_clear (our #2490), xma2_source_voice (#2481, vendored-FAudio gate). The third red, the sparse tile video-memory test, is a known batch flake (green solo).Zero delta from this PR; every test it adds passes inside the suite.
Not tested: gpu suite, Windows native.
Correction: an earlier version of this row reported three extra reds; those runs lacked the
d3d12,d3d12core=n,bDLL overrides and hit stub-DLL NOTIMPL artifacts. Re-ran with the standard env, artifacts gone.AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
@sage-sage on GitHub · 2026-11-26 07:05 UTC · original
Test report: passes on NVIDIA. Exact head
8660a459(its base is currentmainb49be18, so head = merged).Tested
cargo test --workspace -- --test-threads=4: 1437 passed, 0 failed, 47 ignored; the 2 new tests passmainon this machine): 21 wave64 tests (NVIDIA is wave32 only), 3 per-lane wave32 f16/f32 forms (refused), 3 D3D12 debug layer (d3d12SDKLayers.dllnot installed), 1no heap windows, 1pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off)Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
github-bot referenced this pull request2026-11-26 12:40:17 +00:00
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.