mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
EnvBuilder.setdefault already reads os.environ.get(key).strip() and prefers it over the computed value. Three handlers repeated that check in front of eb.set: four dead lines each plus an import, restating a contract that lives one module over. If setdefault ever changes, the three copies do not follow. Behaviour is identical and was measured on both paths: each handler yields the same derived value as before, and with os.environ[KEY] set the override still wins. The only change in flow is that an overridden value is now computed and discarded, costing one df or /proc read per make dotenv. The host-path guard in registry_cache_max_size stays: it prevents a df on an empty path, which is a different concern from the override. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
21 lines
614 B
Python
21 lines
614 B
Python
"""INFINITO_CACHE_PACKAGE_HEAP: Nexus JVM heap size (half of MemAvailable,
|
|
cap 2g, floor 1g)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from utils.env.runtime import mem_available_mb
|
|
|
|
if TYPE_CHECKING:
|
|
from utils.env.builder import BuildContext, EnvBuilder
|
|
|
|
KEY = "INFINITO_CACHE_PACKAGE_HEAP"
|
|
COMMENT = "Nexus JVM heap size (half of MemAvailable, cap 2g, floor 1g)."
|
|
|
|
|
|
def apply(eb: EnvBuilder, ctx: BuildContext) -> None:
|
|
ram_mb = mem_available_mb()
|
|
heap_gb = 1 if ram_mb <= 0 else max(1, min(ram_mb // 2048, 2))
|
|
eb.setdefault(KEY, f"{heap_gb}g", comment=COMMENT)
|