Part of #4516: Windows renders start workers only for the cores the process may use

The renderer sized its worker pool from available_parallelism, which on
Windows counts every processor in the machine, also when the process's
affinity mask allows fewer. A process allowed one core started 8 workers,
and the renderer's flush spun on that core while the workers got no time,
so renders crawled or stalled.

The desktop app and vectorcraft-cli now read the affinity mask at startup
(src/windows_cores.rs, shared) and pass the count to the renderer with
vectorcraft_render::set_usable_cores. With one usable core the renderer
renders on the calling thread.
This commit is contained in:
dotCooCoo
2026-10-31 18:44:55 +07:00
committed by bflatastic
parent 663e691908
commit 4e785b40ce
8 changed files with 121 additions and 8 deletions
+3 -2
View File
@@ -34,8 +34,9 @@ winsafe = { version = "0.0.29", default-features = false, features = ["kernel",
# DirectWrite's system font collection and GDI's font list (the desktop app's src/system_fonts.rs,
# shared): fonts that font services such as Adobe Fonts load in place (#579, #1258). MIT OR
# Apache-2.0.
windows = { version = "0.62", features = ["Win32_Graphics_DirectWrite", "Win32_Graphics_Gdi"] }
# Apache-2.0. Win32_System_Threading has `GetProcessAffinityMask`, which the desktop app's
# src/windows_cores.rs, shared, uses to count the cores the process may run on.
windows = { version = "0.62", features = ["Win32_Graphics_DirectWrite", "Win32_Graphics_Gdi", "Win32_System_Threading"] }
# CoreText's font manager (the desktop app's src/mac_fonts.rs, shared): fonts that apps and font
# managers register from their own folders (#579). Zlib OR Apache-2.0 OR MIT.
+7
View File
@@ -49,6 +49,10 @@ mod prefs_dir;
#[cfg(windows)]
#[path = "../../vectorcraft/src/system_fonts.rs"]
mod system_fonts;
/// The desktop app's affinity-mask reader, shared: renders start workers only for usable cores.
#[cfg(windows)]
#[path = "../../vectorcraft/src/windows_cores.rs"]
mod windows_cores;
use serde_json::{Value, json};
use vectorcraft_engine::file_access::{self, AutomationRoots};
@@ -161,6 +165,9 @@ fn help() -> Result<(), String> {
}
fn main() -> ExitCode {
// Before the first render: the cores the process may run on.
#[cfg(windows)]
windows_cores::install();
// Before any font lookup: the fonts font services load (#579).
#[cfg(windows)]
system_fonts::install();