Skip to main content

plan_pressure_evictions

Function
This function is defined in the protocols module.
Return the session_ids to soft-evict, coldest (LRU) first. A pure planner: it takes the container memory budget (typically the cgroup limit), the current anonymous rss_mb and the warm-cache registry, and names the coldest rebuildable caches to shed until RSS is back within headroom_ratio of the budget. It never touches the event loop or the caches themselves — the gateway enacts the returned plan. Guards (a victim is skipped, never evicted, when):
  • in_flight is True — an executing turn must not be aborted, or
  • flushed is False — an unflushed transcript is not yet rebuildable from the store, so evicting it would lose data.
Returns an empty list when RSS is within budget, the budget is unknown (None/<= 0), or nothing evictable remains — so a host that can’t report a cgroup limit simply never soft-evicts (legacy behaviour).

Signature

Parameters

Optional[float]
required
No description available.
float
required
No description available.
Sequence[WarmSession]
required
No description available.

Returns

List[str]
The result of the operation.

Uses

  • math.isfinite
  • evictable.sort

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 3523