Expand description
Environment-variable helpers shared by every crate in the workspace.
The knobs documented in the README (DOCLING_RS_*, DOCLING_*) grew one
hand-rolled std::env::var dance per call site — presence checks that
treated FOO=0 as on, three copies of the same truthiness predicate,
a dozen .ok().and_then(|v| v.parse().ok()) chains. This module is the
single vocabulary for all of them:
flag— boolean knobs (DOCLING_RS_FP32=1);nonempty— string knobs where a blank value means “unset”;parse— numeric knobs with a coded default;debug_enabled/crate::debug_log!— theDOCLING_RS_DEBUGdiagnostics channel.
On targets without an environment (wasm32-unknown-unknown) std::env::var
reports “not present”, so every helper falls back to its default — the
wasm builds keep compiling with no cfg noise at the call sites.
Functions§
- cgroup_
memory_ limit_ mb - The container’s memory limit in MB from the cgroup files (v2
memory.max, v1memory.limit_in_bytes),Nonewhen unlimited — both spell “no limit” as either the literalmaxor an enormous sentinel (>= 2^60 bytes). - cpu_
budget - The CPU budget thread-pool sizing should derive from: host parallelism
clamped by the container’s cgroup CPU quota (#262).
available_parallelismis quota-aware on common setups, but container runtimes exist where it still reports the host cores (docling.rs#262’s 8 threads under a 4-CPU limit), so the quota files are read directly as an extra clamp — a limited container must never size pools past its throttle ceiling. On non-Linux (and wasm) the quota reads simply fail and the host count stands. - debug_
enabled - Whether
DOCLING_RS_DEBUGdiagnostics are on. Cached on first use: the callers sit inside per-page pipeline loops, and a process does not meaningfully flip its own debug env mid-run. - flag
- True when
keyis set to a truthy value. Truthy is anything except the explicit “off” spellings — empty,0,false,no,off(trimmed, ASCII case-insensitive) — so bothFOO=1andFOO=yesenable, andFOO=0actually disables instead of counting as “present, therefore on” (the trap the oldenv::var(..).is_ok()checks all shared). - nonempty
- The trimmed value of
key, if set and non-blank. TheOptionshape makes “env override, else default” read asnonempty(K).unwrap_or_else(..)and composes with.or_elsechains for multi-variable fallbacks. - parse
keyparsed asT, if set and parseable. Unparseable values fall back to the coded default silently — tuning knobs degrade, they don’t error.- rss_mb
- This process’s resident set size in MB (
/proc/self/statusVmRSS);Noneoff Linux. The number admission control (#263) compares against the memory ceiling.