kongbai01203 (plugins#853) saw pf-serve hold ~1.82 GB of private memory
on Windows after the first redaction, until it was ended for idling. On
the CPU path pf-v3 read the whole 1.6 GB q8 GGUF into a malloc'd buffer;
the rest is ~200-270 MB of compute buffers. pf-v4 (691a10446,
weights-paged.patch) maps the file read-only instead, so the weights are
file pages the system can drop and share, not pf-serve's own memory.
Metal and Vulkan load as before.
This pins pf-v4's five zips (sha256 checked against the release's
downloads) and keeps pf-v3 in oldTags, so a user with pf-v3 on disk runs
it until upgrade() has fetched pf-v4. The idle unload stays 10 minutes
after the last request (idleAfter); the reporter's ~25 min was that
timer restarting on each request.
Measured, pf-serve on the CPU, private bytes (commit charge):
- Windows (xiaomi-gpu): v3 1,749 MB after load, 1,822 MB after a 78K-char
text; v4 200 MB and 273 MB. pf-serve-base the same. Working set v4
1,363 MB, file pages.
- macOS (mote): physical footprint 1.7-1.8 GB on v3, 209-303 MB on v4.
- Spans (text, offsets, score, all hashed) are identical v3 vs v4 for
pf-serve, pf-serve-base and pf-serve-vulkan on four texts, 261 to
78,300 chars. Vulkan on the iGPU: ~1.9-2.1 GB private on both, the
driver's.
- End to end on Windows through pii.Find with a sandbox XDG_CACHE_HOME
holding pf-v3 and the model, PF_DEVICE=cpu: magpie downloaded pf-v4
through the pinned sha, ran it at 220 MB private, and removed pf-v3.
Test: TestRealServeOnTheCPUMapsTheModel (PII_REAL_SERVE, PII_REAL_DIR)
starts the real pf-serve on the CPU, checks the first span of a long
text, and fails when its own memory is over half the model. Broken by
hand by pointing it at pf-v3's binary: red on Windows (1,821 MB), WSL
Linux (1,822 MB) and mote (1,843 MB); green on pf-v4 at 272, 276 and
297 MB. It skips without the env vars, so CI doesn't download 1.6 GB.
Run on mote at 691a10446 plus this change: gofmt -l internal/pii
(clean), GOOS=windows/linux go vet ./internal/pii, go test -count=1
./internal/pii, and under lockf suite.lock go test -count=1
-timeout 45m ./...: every package ok, exit 0 (a first try was cut off
when mote rebooted). Main then gained 2fe4e9c70 in internal/pii
(serve.go, not classifyTimeout); rebased onto c66cdbea9 and run again
there: gofmt, the three go vets and go test ./internal/pii ok on mote,
go test ./internal/pii and the real test ok on Windows (272 MB). The
real test on mote at the rebased head ran out of classifyTimeout's 34s
at load 108 (others' suites; 9.5s on Windows, green on mote before at
normal load) and was not rerun there; the full suite was not rerun at
the rebased head.
Not tried: a machine actually under memory pressure (that the pages are
dropped and read back is the OS's doing), CUDA builds (none shipped),
and linux-arm64/darwin-amd64 beyond their checksums.
Reported-by: kongbai01203