mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4671] [Engine] the PLE table lock is refused under systemd's default 8 MiB memlock: the residency policy admits it without checking RLIMIT_MEMLOCK #2127
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#2127
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?
Originally created by @liaiwu on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4671
Problem
A systemd service that does not set
LimitMEMLOCKruns withRLIMIT_MEMLOCK = 8 MiB. The 0.2.7 PLE residencypolicy decides to lock the table from RAM figures alone, the kernel refuses the 26.8 GiB
mlock(), and theengine keeps serving normally with the table faulted in but reclaimable. Two start-up lines are the only sign;
nothing fails and nobody restarts.
Measured on this box, that state costs +6.0% of decode on one workload (six runs against six, Welch t=5.1)
and +2.6% on another, which the sample cannot separate. This is the default path: the start-up line has no
--ple-ioat all, the policy pickedramon its own.Environment
Strata
870aedd9(v0.2.8), engine0.1.54(the binary's own--version). Ubuntu 24.04, kernel 6.8.0-52, oneRTX 4090 24 GB (sm_89), Intel i7-14700KF (AVX2), 125.6 GiB RAM, driver 580.178.04, built against CUDA 12.8.
Model Qwen3.8-Flash-Next, ISTA-DASLab GSQ-RCO IQ3_S. PLE table 26.8 GiB (
320001536 rows), pinned expertarena 46.84 GiB, MTP on.
The running engine's
args(/proc/<pid>/cmdline, no--ple-io):Started by a hand-written systemd unit (
ExecStart->run.sh->serve/server.py), not bysetup.py—which is where the memlock limit would have been raised.
Reproduce
Start with no
LimitMEMLOCKand no drop-in. Read/proc/<pid>/limits:A login shell on the same machine reports 15.7 GiB, so starting the same command from a terminal does not
reproduce it.
The start-up log then shows:
/proc/<pid>/statusshowsVmLck: 0 kB, and/proc/meminfoshowsMlocked: 11104 kB(nothing of the table).Add a drop-in
/etc/systemd/system/<unit>.service.d/memlock.confcontaining[Service]andLimitMEMLOCK=infinity, thendaemon-reloadandrestart. Nothing else changes — same unit, same config,same model files. The start-up line becomes:
and
VmLckis28125136 kB,Mlocked26.83 GiB — exactly the table.Expected
Either the policy does not pick a locked table that this process cannot lock, or the refusal says what it is
worth. The policy's own arithmetic —
ple_resident_admit(include/strata/core/ple_residency.hpp:23, calledat
src/program/generate.cpp:4693) — compares table + expert arena + 8 GiB headroom against available RAM andnever reads
RLIMIT_MEMLOCK, so it says yes and the kernel says no. The#4518back-out(
ple_lock_blocks_cache, same header, line 43) then reasons about the lock as if it had succeeded.What the refusal costs
Same machine, same unit, same config, same model; the arms alternate, and the only difference between an arm
pair is that drop-in. Two fixed request bodies (md5 pinned,
fa6015c823765aab5426127c72819facand454bc519cca732a5d1a94b41e31923d0), three runs per arm, every requestfinish_reason: stopwith non-nullcontent.
predicted_per_secondfrom the server's owntimings. Decode tok/s:Pooled, six runs per side:
throughput, not better speculation.
prompt_msis ~960 msagainst ~105 ms for the later ones), so the table also gives the figure with that run dropped; the direction
is unchanged.
number to use: that round's arms sat inside different amounts of conversation-cache activity (28 against 37
park/restore log lines in the two start-ups), which the redo controlled by holding the cache configuration
fixed and alternating the arms. Why it inflated the earlier figure is not established.
What the lock itself costs the host
Read in the same session, the same unit and config, only the drop-in different:
/proc/meminfoMlocked/Unevictableused(fromfree)buff/cacheVmRSS/RssAnon/RssFileVmSwapThe engine's own footprint does not grow; 26.8 GiB moves from reclaimable file pages into unevictable ones.
The engine's own
VmSwapstays 0 in both states, so any memory pressure from locking lands on other processes.Two things I am not claiming here:
MemAvailableread 66.0 GiB unlocked and 41.4 GiB locked, but the tworeads were not at the same point in the session's life, so the size of that change is not measured; and
swap in use barely moved between those two reads, although earlier in the day I saw it go from 6.7 MiB to
959 MiB after the lock was raised — that was under hours of load, and I did not identify what got swapped.
Suggested change — scope to be agreed, no patch offered
getrlimit(RLIMIT_MEMLOCK)intople_resident_admit. When the limit is below the table, either keepthe direct reads, or pick the mapped-but-unlocked table and say so, rather than admitting a lock that will
be refused.
src/kernels/ngram.cpp:461) state what the lock is worth, since the engine keepsserving and nothing else prompts a restart.
Say the word if either is unwanted and I will drop it.
Reproduction status
Reproduced locally on one machine: four alternating arms, six runs against six, and the state itself confirmed
by
/proc/<pid>/limits,VmLck,Mlockedand the two start-up lines above.Not verified / not run
n-gram table per token and an unlocked table competes with the 46.84 GiB pinned arena for reclaimable RAM;
I measured no page-fault or reclaim counters to support it.
prompt_msper arm's first run is ~960 ms against ~105 ms later);no prompt-side figure is claimed.
the checkout, not the installer.
decode by -0.3% / -0.5%" comes from the earlier, less controlled round and carries its caveat.
can the two request bodies and the small A/B script.
Related
the memlock limit — that is the setup path, not a hand-written unit, and the PR is not in 0.1.54. This issue
is about the admission decision, which both the old and the new shape make the same way.
--ple-io directagainst--ple-io ramand found no gain. That is a differentcomparison: both of its arms had
ulimit -l unlimited, and neither arm is "the table is in RAM but its lockwas refused".
AI disclosure
Written with an AI assistant (Claude, Anthropic) working on my machine at my direction: it read the source and
my logs and drafted this text. The restarts, the runs and the numbers are mine; every line reference above was
checked against
870aedd9, and the log lines were copied from the engine log rather than retyped.@alexanderi96 commented on GitHub (Oct 31, 2026):
One arm that might be worth adding:
--ple-io direct. It reads rows withO_DIRECTthrough a ~90 MB row cache, so the table costs neither locked memory nor page cache. #1211 measured direct against ram with both arms locked and found no gain for ram; if that still holds on your box, direct would give back the decode you measured without making 26.8 GiB unevictable. Data point, not a measurement: on a 64 GB host with a 32 GiB arena the residency policy picks direct on its own (table + arena + 8 GiB headroom does not fit).@liaiwu commented on GitHub (Nov 2, 2026):
Following up on @alexanderi96's suggestion: we ran the
--ple-io directarm on the 4090 box from #4671. Result on this machine is no consistent direction — neither the win nor the loss that was predicted.What was changed (one thing at a time): the config's
argsgot exactly two entries appended,"--ple-io", "direct". Every other argument is byte-identical (--vram-reserve-mib 244,--kv int8 --kv-resident 32768,--conversation-cache-mib 32768 --conversation-cache-slots 8,--pool-workers 13,--max-context 262144,--spec 4 --spec-min-p 0.5). Engine 0.1.54 (870aedd9), one RTX 4090 (23.988 GiB, sm_89), 125.6 GiB RAM, model Qwen3.8-Flash-Next GSQ-RCO IQ3_S, storage three Samsung 980 PRO 2TB in Linux RAID5 (/proc/mdstat: level 5, 32k chunk,[3/3][UUU]). The machine is dedicated to Strata.@alexanderi96's mechanism claim is confirmed here. Read from the running process while direct was up:
Mlocked11,104 kB andUnevictable11,112 kB — against 26.83 GiB for both when the table was locked; the engine's ownVmLckwas 0 kB.49,116,200 kB= 46.84 GiB anon (that is thecudaHostRegisterexpert arena) and6,695,924 kBanon; the third largest is 329,800 kB.grep -E "\.bin|\.gguf|ngram|ple" /proc/<pid>/mapsreturned nothing at all — the n-gram table is not mapped in the first place.So the 26.8 GiB really is off the resident side, not relabelled. GPU side does not move:
expert cache 8591 slots, 16.29 GiB(8594 slots / 16.30 GiB when locked). Startup probe:PLE direct read probe: 106371 rows/s (fine).Decode, binned by prompt length — median tok/s with n; first request after each engine start dropped; only requests that generated ≥200 tokens. Same machine, same day, single engine start per arm (locked 09:41–10:36, direct from 10:36):
directram+ lockedDraft acceptance (median over all requests): 68.9% direct vs 69.2% locked. Prompt re-read cost:
222,424 read in 70,336 ms= 3,162 tok/s on direct vs199,506 read in 63,767 ms= 3,129 tok/s on the locked arm (different prompt sizes, so treat as same shape, not as a pair).Two adjacent bands land on opposite sides of zero, both just outside the +-4-5% run-to-run spread we measured on this box with repeated identical request bodies. Our reading: no consistent direction — session and context composition, not the ple-io mode.
This is an observation, not a controlled comparison. Unconfirmed as such: request bodies are whatever the live sessions issued (not md5-pinned, not the same prompts in each arm); one engine start per arm, so start-to-start drift is not controlled; n=3 in the 20-40K band; conversation-cache activity per arm was not designed into the comparison (counted afterwards: 49 parked/restored lines on the direct arm vs 45 on the locked arm).
Not run: a
D L L Dalternating-restart comparison with a pinned pair of request bodies, and a dedicated ~20K-token prompt body — which is exactly where @fioruccione saw direct lose (-3.2% decode, -4.4% prefill at 20K, non-overlapping ranges) and which we only covered through natural traffic. We also did not measure raw NVMe bandwidth, deliberately: pushing IO at a model file behind a serving backend risks stalling prefill.Why we still went back to
ram+ locked — not because direct measured slower. At an indistinguishable speed range, locked is the side with a controlled comparison behind it (+6.0% over unlocked here, six vs six, Welch t=5.12; +0.2% on @fioruccione's box), it keeps PLE reads off the NVMe path entirely, and it is the configuration all of our baselines were measured on. Freeing 26.8 GiB bought nothing on this machine:MemAvailablewas 60.1 GiB under direct vs 38.1 GiB locked, against a physical park gate that only refuses below 2.5 GiB available.Where @alexanderi96's reasoning does hold: direct really is close to free on this box, because the disks are fast and PLE reads are pure reads, so RAID5's read-modify-write penalty never enters. A box with a spinning disk, or memory tight enough that the residency policy picks
directby itself, is a different case — and on such a boxdirectis also the only option that actually removes those 26.8 GiB from memory rather than moving them into the reclaimable column.Read-only checks anyone can repeat while an engine is running:
Still unexplained on both machines: the mechanism behind the per-machine memlock difference.