Skip to main content

Module sysmem

Module sysmem 

Source
Expand description

The memory available to this process and the default query budget sized from it (native targets only). How much memory this process can still use, and the default query budget that follows from it.

A lazily opened file caps its dictionary, tile and block caches with a memory budget (crate::Rete::set_memory_budget). A fixed default of [DEFAULT_QUERY_BUDGET_MB] (4096 MiB) is more than a 4 GiB container holds before the query’s own working state is counted, so the default is sized from the memory actually available instead: half of it, at least MIN_DEFAULT_QUERY_BUDGET_MB, at most the old fixed figure. RETE_QUERY_BUDGET_MB overrides the default, and an explicit budget (the CLI’s --memory-budget-mb, a client’s set_memory_budget) wins over both.

The probe is the one the CLI’s memory-aware local open uses: the smaller of the kernel’s MemAvailable and the headroom under every cgroup memory limit above the process.

Constants§

MIN_DEFAULT_QUERY_BUDGET_MB
The lowest default query budget, whatever the memory probe says: below it the caches thrash rather than save memory (one decoded dictionary chunk or index tile is 64 KiB to a few MiB).
QUERY_BUDGET_ENV
The environment variable that overrides the default query budget, in MiB (0 = unlimited).

Functions§

available_memory
Bytes this process can still allocate before something kills it: the smaller of the kernel’s MemAvailable and the headroom under every cgroup memory limit above the process (v2 memory.max, or v1 memory.limit_in_bytes). Inside a container MemAvailable describes the whole VM, so the cgroup limit is the one that matters there. Reclaimable page cache (inactive_file) does not count as used. None when neither source is readable (not Linux).
default_query_budget_mb
The default query budget in MiB (0 = unlimited) for this process: RETE_QUERY_BUDGET_MB when set, else sized from available_memory (see default_query_budget_mb_from).
default_query_budget_mb_from
default_query_budget_mb with its inputs explicit: env_mb is the override (it wins outright, 0 = unlimited), available the bytes the process can still allocate (None = unknown, which keeps the fixed [DEFAULT_QUERY_BUDGET_MB]). Otherwise half the available memory, clamped to [MIN_DEFAULT_QUERY_BUDGET_MB, DEFAULT_QUERY_BUDGET_MB].