Skip to content

ple: --ple-io ram locks the n-gram table in RAM (no SSD read on the prompt/token path) - #202

Closed
q8atnight wants to merge 2 commits into
Niko1221:mainfrom
q8atnight:pr/ple-io-ram
Closed

q8atnight wants to merge 2 commits into
Niko1221:mainfrom
q8atnight:pr/ple-io-ram

Conversation

@q8atnight

Copy link
Copy Markdown
Contributor

Summary

A third --ple-io mode: ram = the mmap mapping with the whole table mlocked at open, so no SSD read ever
sits on the prompt or token path. madvise(MADV_WILLNEED) first, then mlock; a start log line reports the time
it took. One commit on top of 0.1.27 (a790805). direct stays the default and mmap is unchanged; the ngram
files are untouched upstream, so the change is the PleIoOptions::lock flag, its open() handling, and the
option plumbing.

Measured

On 2x RTX 3090, IQ3_S, 121 GB RAM: stock --ple-io direct reads the 28.8 GB table with O_DIRECT, and a cold 32K
prompt waited ~3 s on those reads. With ram the table is mapped and locked once at start, and no table read
touches the SSD again. In use on our box since 2026-09-28 with no issue.

Cost and failure mode

ram costs host RAM = the table size (28.8 GB here; our IQ3_S dual setup uses ~82 of 121 GB). If mlock is
refused — ulimit -l too low, Docker's default memlock is 64 KB — the engine does NOT fail: it prints
strata: PLE table mlock failed (...): touching its pages instead and touches every page, so the table still
enters the page cache but the kernel may evict it under memory pressure. For the lock itself to hold, start with
ulimit -l unlimited (Docker: --ulimit memlock=-1). The log line
strata generate: PLE table locked in RAM (--ple-io ram) in X s distinguishes the two outcomes.

Switch

--ple-io ram is opt-in; direct (and mmap) behave exactly as before.

@Niko1221

Copy link
Copy Markdown
Owner

Nice and small. Please (1) refuse ram on Windows or print that it acts as mmap there, (2) print 'locked' only when mlock succeeded, else 'loaded (not locked)', and (3) drop the box-specific comments and tidy the --help line. Then we'll merge.

dsh and others added 2 commits September 30, 2026 14:09
…mlock succeeded else 'loaded (not locked)', neutral comments + --help (review)
@q8atnight

Copy link
Copy Markdown
Contributor Author

All three done and pushed (rebased on 0.1.28, builds clean):

  1. On Windows, --ple-io ram now refuses with a clear message (mlock has no equivalent there).
  2. The startup line prints locked only when mlock actually succeeded; otherwise
    loaded (not locked).
  3. Box-specific comments dropped, --help line tidied.

Also: close() resets the flag (the unmap releases the lock). Thanks — happy it landed small.

@Niko1221

Copy link
Copy Markdown
Owner

Released in 0.1.29: --ple-io ram with the Windows refusal and the honest 'locked' message. Merged under your name (cherry-picked, so GitHub doesn't show it as merged). Thank you!

@Niko1221 Niko1221 closed this Sep 30, 2026
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.

2 participants