Central sizing policy for memory-sensitive queues and caches.
The limits here are startup/default guardrails. Live pressure response still
belongs to Ferricstore.MemoryGuard; this module decides the safe default
size for structures that otherwise grow independently of MemoryGuard:
- WARaft segment-log ETS tail cache
- WARaft apply-projection cache before segment projection compaction
- Flow history projector pending queue
- Flow LMDB writer mailbox and per-enqueue batch size
Explicit application env always wins. When a key is unset, defaults are derived from RAM, disk free space, CPU count, and shard count.
Summary
Functions
Returns all adaptive limits for a hardware profile.
Returns the hardware profile used by adaptive limits.
Returns a configured or adaptive limit for a guardrail key.
Clears the cached adaptive default snapshot.
Types
@type limit_key() ::
:flow_history_projector_max_pending_entries
| :flow_lmdb_writer_max_mailbox_messages
| :flow_lmdb_writer_max_enqueue_ops
| :waraft_segment_log_max_ets_bytes
| :waraft_segment_log_max_ets_entries
| :waraft_segment_log_min_ets_entries
| :waraft_apply_projection_cache_max_entries
Functions
Returns all adaptive limits for a hardware profile.
Returns the hardware profile used by adaptive limits.
@spec limit(atom(), non_neg_integer() | :infinity) :: non_neg_integer() | :infinity
Returns a configured or adaptive limit for a guardrail key.
false, :infinity, "off", "false", and "infinity" intentionally
disable a cap and return :infinity.
@spec reset_cache() :: :ok
Clears the cached adaptive default snapshot.
Production code normally keeps one startup-sized snapshot so hot-path callers do not rescan RAM/disk/CPU state. Tests and config reload paths can reset it before constructing new workers.