Skip to content

Stage 4: cross-platform windows_threading::submit (Win32 fast path + std::thread::spawn fallback) - #4345

Merged
Kenny Kerr (kennykerr) merged 6 commits into
masterfrom
copilot/update-cross-todo-documentation
Apr 30, 2026
Merged

Stage 4: cross-platform windows_threading::submit (Win32 fast path + std::thread::spawn fallback)#4345
Kenny Kerr (kennykerr) merged 6 commits into
masterfrom
copilot/update-cross-todo-documentation

Conversation

Copilot AI commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Continues docs/cross-todo.md Stage 4. The threading_bench example added previously was run on Windows:

Workload win32-pool std::spawn Ratio
single 15.67 µs · 63 813/s 67.20 µs · 14 880/s ~4.3×
burst 0.46 µs · 2 180 027/s 41.16 µs · 24 296/s ~90×
steady 0.46 µs · 2 162 686/s 42.15 µs · 23 724/s ~91×

Per-submit cost on the Win32 pool drops from 15.67 µs (cold) to 0.46 µs (warm) — clear worker-thread reuse — while std::thread::spawn stays flat at ~42 µs paying a full CreateThread per call. Well past the "≥ 5–10× in steady" threshold from the original decision rule, so: keep the windows-threading dependency in windows-future and make submit itself cross-platform.

Changes

  • crates/libs/threading/Cargo.toml — new default-on std feature.

  • crates/libs/threading/src/lib.rs — drop the crate-wide #![cfg(windows)]. submit gains three cfg-gated bodies:

    • Windows (any feature config): unchanged Win32 fast path through TrySubmitThreadpoolCallback.
    • Non-Windows + std (default): std::thread::spawn(f), fire-and-forget.
    • Non-Windows + no_std: unimplemented!() — links but signals at runtime that no portable thread primitive is configured.

    The Win32 surface (Pool / for_each / thread_id / sleep, the bindings module, check / try_submit helpers) stays Windows-only via #[cfg(windows)]. The crate-level expect(non_snake_case, ...) lint group is also gated to Windows since those idents only exist there.

  • .github/workflows/linux.ymlwindows-threading and windows-future added to the build and doc loops; windows-threading also added to the --no-default-features build loop so the no_std-without-std path stays green.

  • docs/cross-todo.md — Stage 4 rewritten with the measured numbers, the decision, and the implementation. Marked ✅ done.

Runtime async tests under crates/tests/libs/future/ are intentionally untouched — they go through RoInitialize/COM and stay Windows-only; only the build/doc paths of windows-future are exercised on Linux. This unblocks Stage 5 (windows-collections on Linux).

Copilot AI and others added 5 commits April 30, 2026 16:31
…Linux"

This reverts commit 59483ec.

Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/windows-rs/sessions/331f0b09-e89f-4b3c-bede-e6e23afa6f0c

Co-authored-by: kennykerr <9845234+kennykerr@users.noreply.github.com>
@kennykerr
Kenny Kerr (kennykerr) merged commit eb52760 into master Apr 30, 2026
27 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the copilot/update-cross-todo-documentation branch April 30, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants