[PR #42] [MERGED] pinned: MEM_LARGE_PAGES on Windows never worked - enable the privilege, round the size #2427

Closed
opened 2026-11-04 02:00:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/42
Author: @pipeob0
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/28/2026
Merged by: @Niko1221

Base: main ← Head: gh/large-pages


📝 Commits (2)

  • 0bf3216 pinned: enable SeLockMemoryPrivilege and round the arena to GetLargePageMinimum
  • fb1fb57 pinned: say how many bytes were refused, and stop blaming the privilege

📊 Changes

1 file changed (+31 additions, -5 deletions)

View changed files

📝 src/core/pinned.cu (+31 -5)

📄 Description

Why

The pinned expert arena asks for MEM_LARGE_PAGES but on Windows it could never get them, for two
independent reasons, and the log blamed a privilege the user had often already granted.

1. The privilege is never enabled in the process token. Having Lock pages in memory assigned to the
account is not enough — VirtualAlloc returns ERROR_PRIVILEGE_NOT_HELD (1314) unless the process calls
AdjustTokenPrivileges for itself first. The code only had a comment about the privilege. This is what made
the message misleading: granting the privilege, rebooting, and starting the engine printed the same
"needs SeLockMemoryPrivilege" line, because a different reason was now the blocker.

2. The size was passed unrounded. VirtualAlloc with MEM_LARGE_PAGES requires a size that is an exact
multiple of GetLargePageMinimum (2 MiB). The arena size is not, so the call failed with
ERROR_INVALID_PARAMETER (87) — a parameter error that reads exactly like the privilege problem in the log.
Rounded up: the slack is under 2 MiB and the tail is never touched.

Both fixed, on a desktop account with the privilege granted:

expert arena: cudaHostRegister PORTABLE ok; large pages (2097152 B)

The refusal note now distinguishes three different failures

1450 (ERROR_NO_SYSTEM_RESOURCES: the large-page pool does not have that many 2 MiB pages free right
now
), 87 (size not a multiple) and 1314 (the privilege really is off) all printed one identical line.
Seen for real while A/B-ing this: a run started minutes after an engine process was killed printed 1450, and
the next run succeeded — the killed process had not released its pinned pages yet. Note that this is a
state symptom (a dying engine still holding pinned memory) reported as a privilege problem, which is the
kind of thing worth being able to tell apart when reading a stall report (#31).

The second commit adds the requested byte count and stops asserting the cause.

Testing

  • STRATA_NO_LARGEPAGES=1 skips the attempt entirely, so the same boot can be A/B'd.
  • End-to-end on a 5700X3D + RTX 5060 Ti, native swift-iq3_xxs pack, medians of interleaved runs:
    neutral here (48.8 ms/round without, 49.7 with). Reported as such: the reason to land this is that the
    arena ends up being what the code says it is, and that the log tells the truth. Boxes with a much bigger
    arena, or a heavier expert pool, have more TLB pressure to save than this one.

No ABI or behaviour change for anyone who cannot get large pages: same 4 KiB fallback as before.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/42 **Author:** [@pipeob0](https://github.com/pipeob0) **Created:** 9/28/2026 **Status:** ✅ Merged **Merged:** 9/28/2026 **Merged by:** [@Niko1221](https://github.com/Niko1221) **Base:** `main` ← **Head:** `gh/large-pages` --- ### 📝 Commits (2) - [`0bf3216`](https://github.com/Niko1221/Strata/commit/0bf3216e538d76bf30b3b332e9554f99fbed21aa) pinned: enable SeLockMemoryPrivilege and round the arena to GetLargePageMinimum - [`fb1fb57`](https://github.com/Niko1221/Strata/commit/fb1fb57e57961dedeb7e2df990b7cf29ef9af2db) pinned: say how many bytes were refused, and stop blaming the privilege ### 📊 Changes **1 file changed** (+31 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/core/pinned.cu` (+31 -5) </details> ### 📄 Description ### Why The pinned expert arena asks for `MEM_LARGE_PAGES` but on Windows it could never get them, for two independent reasons, and the log blamed a privilege the user had often already granted. **1. The privilege is never enabled in the process token.** Having *Lock pages in memory* assigned to the account is not enough — `VirtualAlloc` returns `ERROR_PRIVILEGE_NOT_HELD` (1314) unless the process calls `AdjustTokenPrivileges` for itself first. The code only had a comment about the privilege. This is what made the message misleading: granting the privilege, rebooting, and starting the engine printed the same "needs SeLockMemoryPrivilege" line, because a *different* reason was now the blocker. **2. The size was passed unrounded.** `VirtualAlloc` with `MEM_LARGE_PAGES` requires a size that is an exact multiple of `GetLargePageMinimum` (2 MiB). The arena size is not, so the call failed with `ERROR_INVALID_PARAMETER` (87) — a parameter error that reads exactly like the privilege problem in the log. Rounded up: the slack is under 2 MiB and the tail is never touched. Both fixed, on a desktop account with the privilege granted: ``` expert arena: cudaHostRegister PORTABLE ok; large pages (2097152 B) ``` ### The refusal note now distinguishes three different failures `1450` (`ERROR_NO_SYSTEM_RESOURCES`: the large-page pool does not have that many 2 MiB pages free *right now*), `87` (size not a multiple) and `1314` (the privilege really is off) all printed one identical line. Seen for real while A/B-ing this: a run started minutes after an engine process was killed printed 1450, and the next run succeeded — the killed process had not released its pinned pages yet. Note that this is a *state* symptom (a dying engine still holding pinned memory) reported as a privilege problem, which is the kind of thing worth being able to tell apart when reading a stall report (#31). The second commit adds the requested byte count and stops asserting the cause. ### Testing - `STRATA_NO_LARGEPAGES=1` skips the attempt entirely, so the same boot can be A/B'd. - End-to-end on a 5700X3D + RTX 5060 Ti, native `swift-iq3_xxs` pack, medians of interleaved runs: **neutral** here (48.8 ms/round without, 49.7 with). Reported as such: the reason to land this is that the arena ends up being what the code says it is, and that the log tells the truth. Boxes with a much bigger arena, or a heavier expert pool, have more TLB pressure to save than this one. No ABI or behaviour change for anyone who cannot get large pages: same 4 KiB fallback as before. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:01 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2427
No description provided.