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
MemAvailableand the headroom under every cgroup memory limit above the process (v2memory.max, or v1memory.limit_in_bytes). Inside a containerMemAvailabledescribes the whole VM, so the cgroup limit is the one that matters there. Reclaimable page cache (inactive_file) does not count as used.Nonewhen neither source is readable (not Linux). - default_
query_ budget_ mb - The default query budget in MiB (
0= unlimited) for this process:RETE_QUERY_BUDGET_MBwhen set, else sized fromavailable_memory(seedefault_query_budget_mb_from). - default_
query_ budget_ mb_ from default_query_budget_mbwith its inputs explicit:env_mbis the override (it wins outright,0= unlimited),availablethe bytes the process can still allocate (None= unknown, which keeps the fixedDEFAULT_QUERY_BUDGET_MB). Otherwise half the available memory, clamped to[MIN_DEFAULT_QUERY_BUDGET_MB, DEFAULT_QUERY_BUDGET_MB].