mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4105] [Engine] --ple-io ram: read the PLE table into page-locked RAM with the unbuffered reader instead of faulting it in through the page cache #4901
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4901
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4105
Author: @chenyb999-zhcn
Created: 10/25/2026
Status: 🔄 Open
Base:
main← Head:engine-ple-populate📝 Commits (1)
8f81ceeple: --ple-io ram reads the table into page-locked RAM with the unbuffered reader instead of faulting it in through the page cache: one MADV_POPULATE_READ walks the 26.8 GiB table one 4 KiB fault at a time (120.1 s, 240 MB/s on the box of #4104, cold) and eight parallel populate chunks are worse, not better (266.2 s - the chunks' read-ahead competes for the same window), while this same drive does 940 MB/s for the engine's unbuffered expert-complement copy; so map an anonymous region, lock it first (no swap window while it is filled), read the table into it with 4 MiB O_DIRECT requests over eight workers (23.7 s, 1215 MB/s measured, mlock 5.8 s) and point the row readers at it - the row path is unchanged, and the page-cache populate stays as the fallback for kernels without MADV_POPULATE_READ or a refused lock; cache-warm startup is unchanged (0.3 s), and the table no longer occupies 26.8 GiB of page cache (#4104)📊 Changes
1 file changed (+99 additions, -22 deletions)
View changed files
📝
src/kernels/ngram.cpp(+99 -22)📄 Description
Closes #4104
Problem and result
--ple-io rambrings the 26.8 GiB PLE n-gram table into RAM at startup and locks it. The path it used was the pagecache:
madvise(MADV_WILLNEED)plus a 16-thread page-by-page toucher (the original shape), then oneMADV_POPULATE_READ(this PR's first shape). On the box of #4104 (2x Tesla V100 32 GB, 96 GB RAM, ZhiTai Ti6001 TB NVMe) a cold start paid for 26.8 GiB:
MADV_POPULATE_READMADV_POPULATE_READchunksEvery page-cache shape is fault driven: each page is its own 4 KiB fault and the read-ahead window is one 128 KiB
request, so more threads only make the windows compete. The engine's own unbuffered expert-complement copy on the
same machine and the same drive does 940 MB/s - that is the shape that reaches the device.
What changed
PleTable::openfor--ple-io ram(POSIX):mlockit before filling it (no swap window while it is being written),platform::read_range_direct- 4 MiB O_DIRECT requests, eight workers, the table'sfile offset and length rounded to 512 bytes as O_DIRECT requires,
impl_->dataat the region; the row readers, the gather path and the prompt path are untouched,close().The page-cache populate stays as the fallback for kernels without
MADV_POPULATE_READor a refused lock, and theWILLNEED + touch loop stays below that.
platform::read_range_directis a small general helper (path, offset, length, destination, workers) that otherstartup loaders use for the same reason.
Validation
Same box, same model, engine 0.1.50 + this commit,
--ple-io ram, launch script withdrop_caches:Limits
The table no longer counts as page cache (it is anonymous locked memory now), so the page cache has 26.8 GiB more
room for the model's shards. The process's RSS is unchanged.
mlockstill needsulimit -l unlimited(setup sets it). A refused lock falls back to the page-cache path andsays so in the log.
Windows is untouched: it has no populate advice, and its existing VirtualLock path stays as it is.
On the reporting box a restart finds the table in the page cache (the mlock is released with the process); the
follow-up series in #4064 adds a
mincoreprobe (platform::resident_fraction) that then takes the populatepath (0.3 s) instead of reading 26.8 GiB again. This PR is the cold path: 120.1 s -> 24.2 s.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.