Skip to content

refactor(fspy-shm): adopt fspy_nostd on Windows - #666

Draft
wan9chi wants to merge 11 commits into
mainfrom
agent/fspy-shm-windows-nostd
Draft

refactor(fspy-shm): adopt fspy_nostd on Windows#666
wan9chi wants to merge 11 commits into
mainfrom
agent/fspy-shm-windows-nostd

Conversation

@wan9chi

@wan9chi wan9chi commented Aug 13, 2026

Copy link
Copy Markdown
Member

Motivation

The Windows preload opens and maps shared memory before main and under the loader lock, where Rust std lazy initialization is not a dependable foundation. This moves the Windows implementation onto no-std Win32 calls while preserving the existing fspy_shm API.

It is the Windows counterpart to #664: fspy_nostd provides small safe wrappers where it can enforce path, handle, or mapping ownership. fspy_shm calls DeviceIoControl and SetFileInformationByHandle directly because their buffer contracts and flags are specific to its sparse-file, sizing, and removal policy. The outer OsStr and io::Error conversion remains for the later public API migration.

Move Windows file handles, sparse-file operations, and mapped views behind direct no-std Win32 wrappers. Keep the existing fspy_shm public API while removing its production memmap2 and direct windows-sys use.

Co-authored-by: GPT-5 Codex <codex@openai.com>
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +1.89%  [ -9.51% .. +17.83%]  overhead   +51.62%
dynamic/access             change  -0.49%  [-24.24% .. +23.67%]  overhead    +6.33%
dynamic/access-relative    change  -0.82%  [-24.55% .. +15.00%]  overhead   +43.70%
static/launch              change  +1.80%  [ -9.08% .. +13.61%]  overhead  +151.73%
static/access              change  +1.59%  [ -4.75% .. +17.66%]  overhead  +958.66%
static/access-relative     change  -1.81%  [ -6.77% ..  +3.85%]  overhead +1349.55%

macos

dynamic/launch             change  +0.09%  [ -1.92% ..  +2.00%]  overhead  +217.30%
dynamic/access             change  -0.37%  [ -3.71% ..  +2.58%]  overhead    +3.26%
dynamic/access-relative    change  -0.10%  [ -2.38% ..  +1.66%]  overhead  +265.91%

windows

dynamic/launch             change  +0.63%  [ -6.41% .. +11.27%]  overhead   +28.09%
dynamic/access             change  -0.26%  [ -5.25% ..  +3.20%]  overhead    +2.21%
dynamic/access-relative    change  -0.76%  [ -4.99% ..  +2.48%]  overhead    +2.29%

wan9chi and others added 10 commits August 13, 2026 13:09
Mirror the std remove_file fallback to FileDispositionInfoEx when DeleteFileW is denied, so dropping a shared-memory keeper removes the pathname while existing handles remain usable.

Co-authored-by: GPT-5 Codex <codex@openai.com>
Replace the policy-heavy map_file helper with one-to-one CreateFileMappingW and MapViewOfFile wrappers. Keep MappingView as the owned RAII view and move shared-memory policy into fspy_shm.

Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
Co-authored-by: GPT-5 Codex <codex@openai.com>
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.

1 participant