erllama_pressure behaviour (erllama v0.1.0)

View Source

Behaviour and helpers for memory-pressure samplers used by erllama_scheduler. A sampler is a stateless module that returns the current {Used, Total} byte tuple for the resource it tracks (system RAM, GPU VRAM, or a custom source).

A sampler MUST be cheap. The scheduler invokes sample/0 on every tick (default 5 s); slow samplers will block the scheduler's mailbox. If a sampler needs to spawn a port (e.g. nvidia-smi), it should cache the previous reading and return it when the call would block, or run its own background poller.

Summary

Types

reading()

-type reading() :: {non_neg_integer(), non_neg_integer()}.

source()

-type source() :: noop | system | nvidia_smi | {module, module()}.

Callbacks

sample()

-callback sample() -> reading().

Functions

available_sources()

-spec available_sources() -> [source()].

sample/1

-spec sample(source()) -> reading().