n-gram table: --ngram-table ram reads it from a locked copy in RAM

embed_lookup_q reads the n-gram table through a row cache and direct reads,
and about half of a step's rows are first-seen, so steps wait on the drive.
--ngram-table ram (default disk, unchanged) copies the table into locked
huge pages in the background, checks the copy against the mapping and then
serves the gather from memory. MemAvailable, RLIMIT_MEMLOCK and the cgroup
limit are checked first; if any is short the table stays on disk. The flag
reaches the plugin as an optional `resident` parameter of embed_lookup_q.
This commit is contained in:
keptn42 authored and StillDeadcode committed 2026-10-05 12:52:50 +02:00
1 parent 4252353bc2
commit e6c8a3d7fa
18 files changed
+363 -56

No files matched your search

+11
View File
@@ -130,6 +130,17 @@ typedef struct RadBuildCtx {
*
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
int64_t max_out_rows;
/* WHERE A HOST GATHER OVER A FILE-BACKED TABLE READS ITS ROWS. 0 -- what a zero-initialised
* context gives -- reads them from the container through the kernel's own row cache, holding
* no more of the table than that. Nonzero asks for the whole table copied into locked host
* memory and read from there: a deployment choice, because it costs the table's size in RAM
* (Qwen3.8-Flash-Next's n-gram table is 47.7 GiB) and buys prefill and throughput, and it
* changes no result. The plugin passes it to `embed_lookup_q` as `resident`; a kernel that
* cannot hold the copy says so and reads the file. --ngram-table disk|ram.
*
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
int ngram_table_ram;
} RadBuildCtx;
/* ================================================================== weights */