Skip to content

perf(fspy): use sparse Windows shared memory#524

Draft
wan9chi wants to merge 17 commits into
linux-memfd-shmfrom
windows-shm-backend
Draft

perf(fspy): use sparse Windows shared memory#524
wan9chi wants to merge 17 commits into
linux-memfd-shmfrom
windows-shm-backend

Conversation

@wan9chi

@wan9chi wan9chi commented Jul 9, 2026

Copy link
Copy Markdown
Member

Motivation

Avoid allocating a fully backed temporary file for each tracked Windows task while keeping file-access recording on the shared-memory fast path.

Background

The Windows adapter relied on shared_memory for mapping creation, naming, and cleanup. Owning the native mapping lets fspy share it by kernel object name, keep sender opens independent of the temporary directory, and mark the backing file sparse.

Windows may write dirty mapped pages under memory pressure. Record writers still use atomics and pointer writes without a file or IPC system call for each record.

Changes

  • Replaces the Windows shared_memory adapter with a small windows-sys implementation and an owned mapped-view guard.
  • Uses UUID identifiers and derives the named mapping from the identifier and expected size.
  • Creates a temporary delete-on-close backing file and marks it sparse before extending it.
  • Treats unavailable sparse-file support as a creation error instead of falling back to full allocation.
  • Opens sender views by mapping name without reopening the backing file or depending on the sender's TMP, TEMP, or working directory.
  • Uses windows-sys imports for LocalFree and PathAllocCombine, replacing linker inputs that the removed dependency supplied.
  • Covers cross-process sharing, owner cleanup, size validation, sparse allocation, changed environments, and production-size endpoint access.

wan9chi commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: adc5221ce4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fspy_shm/src/windows/mod.rs Outdated
@wan9chi wan9chi force-pushed the windows-shm-backend branch from adc5221 to 39b502d Compare July 9, 2026 07:57
@wan9chi wan9chi force-pushed the linux-memfd-shm branch 2 times, most recently from 379cedd to 67534d3 Compare July 9, 2026 14:16
@wan9chi wan9chi force-pushed the windows-shm-backend branch from 39b502d to 29bdc15 Compare July 9, 2026 14:17
@wan9chi wan9chi marked this pull request as draft July 10, 2026 01:16
@wan9chi wan9chi force-pushed the windows-shm-backend branch from 29bdc15 to 9bcba8e Compare July 10, 2026 06:03
@wan9chi wan9chi force-pushed the windows-shm-backend branch 2 times, most recently from 62be316 to 283d922 Compare July 10, 2026 07:04
@wan9chi wan9chi force-pushed the linux-memfd-shm branch 2 times, most recently from 3f7527b to a6a417e Compare July 10, 2026 07:14
@wan9chi wan9chi force-pushed the windows-shm-backend branch from 283d922 to 6691051 Compare July 10, 2026 07:14
@wan9chi wan9chi force-pushed the windows-shm-backend branch 2 times, most recently from 1161f5b to ddfb5f3 Compare July 10, 2026 11:21
@wan9chi wan9chi force-pushed the linux-memfd-shm branch 2 times, most recently from 3994daf to aa6b57e Compare July 10, 2026 11:26
@wan9chi wan9chi force-pushed the windows-shm-backend branch from ddfb5f3 to 13bda67 Compare July 10, 2026 11:26
@wan9chi wan9chi force-pushed the windows-shm-backend branch from 13bda67 to 45c8d2f Compare July 10, 2026 11:33
@wan9chi wan9chi force-pushed the windows-shm-backend branch from 45c8d2f to 6dfcf16 Compare July 10, 2026 13:39
@wan9chi wan9chi changed the title refactor(fspy): own Windows shared-memory mapping perf(fspy): use sparse Windows shared memory Jul 10, 2026
wan9chi and others added 16 commits July 10, 2026 22:52
Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.6 <gpt-5.6@openai.com>

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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>
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>
@wan9chi wan9chi force-pushed the windows-shm-backend branch from 6dfcf16 to 0710119 Compare July 10, 2026 14:59
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