Skip to content

mmap: retire unused Windows file pages from the working set - #438

Open
JohnUzoka wants to merge 1 commit into
PrismML-Eng:prismfrom
JohnUzoka:fix/windows-mmap-retirement
Open

JohnUzoka wants to merge 1 commit into
PrismML-Eng:prismfrom
JohnUzoka:fix/windows-mmap-retirement

Conversation

@JohnUzoka

Copy link
Copy Markdown

Overview

Retire unused Windows file-mapping pages from the working set when llama_mmap::unmap_fragment is called. The Windows implementation currently does nothing, so pages copied to an accelerator can remain resident.

  • Share the existing inward page-alignment helper with the Windows path.
  • Call VirtualUnlock only for complete pages inside the requested fragment; treat ERROR_NOT_LOCKED as the expected unlocked-page case.
  • Keep the mapped view and live boundary bytes intact.
  • Add a Windows-only regression using the real internal mapping implementation and QueryWorkingSetEx, plus test instructions.

This PR is independent of the tokenizer, attention and embedded-adapter changes in the original research branch. It is mechanically extracted from JohnUzoka/llama.cpp@3d1930a, whose base d7b2896 is an ancestor of the current prism; this branch starts at 6447906.

Additional information

Recorded validation, not a new test run

The 2026-11-12 frozen-runtime record records the failing-before reproduction and four passing native checks after the fix. That aggregate is not four mmap-specific cases. The minimal patch and before/after source archive preserve the tested implementation.

No build, tests, linters or formatters were run during this extraction. The newly separated branch has not been independently built. No general RAM, speed or model-quality improvement is claimed; retiring working-set pages does not unmap the Windows view or prevent subsequent refaults.

Requirements

  • Contributing guidelines: inspected while preparing this submission. The contributor remains responsible for reviewing and maintaining the changes; this automated submission does not attest that a human has reviewed every line or accept any agreement on their behalf.
  • AI usage disclosure: YES. AI-assisted research produced the published source changes; an AI agent inspected the diff and recorded evidence, mechanically separated this fix and its existing regression, added test documentation, and prepared this PR. No new runtime validation is claimed.

@github-actions github-actions Bot added documentation Improvements or additions to documentation testing labels Nov 15, 2026

@bri-prism bri-prism left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, the change is small and makes sense: retiring only the full pages inside the fragment and
keeping the view mapped is a safe way to get the POSIX behavior on Windows.

Since the description says this branch has not been built, could you build it on Windows (shared and
static) and run test-mmap-win32 and the existing tests? I want to check the test compiles cleanly
when it pulls llama-mmap.cpp and llama-impl.cpp into the executable with a shared llama build.

Also, nothing here depends on our fork. Would you consider sending it to ggml-org/llama.cpp first?
We would pick it up from there on our next upstream merge, which keeps our mmap code in sync with theirs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants