engine/isolation/resource_limits

Apply OS / V8 resource limits to isolation worker child processes. Engine-internal. Cross-platform: - max_old_space_mb → V8 --max-old-space-size (NODE_OPTIONS) - uv_threadpool_size → UV_THREADPOOL_SIZE - priority → os.setPriority on the child (after spawn) Linux-only (best-effort): - max_rss_mb → prlimit RLIMIT_AS if `prlimit` is available Full cgroups v2 / Windows Job Objects are left to the orchestrator (Docker, systemd, etc.).
Description:
  • Apply OS / V8 resource limits to isolation worker child processes. Engine-internal. Cross-platform: - max_old_space_mb → V8 --max-old-space-size (NODE_OPTIONS) - uv_threadpool_size → UV_THREADPOOL_SIZE - priority → os.setPriority on the child (after spawn) Linux-only (best-effort): - max_rss_mb → prlimit RLIMIT_AS if `prlimit` is available Full cgroups v2 / Windows Job Objects are left to the orchestrator (Docker, systemd, etc.).

Members

(inner, constant) WORKER_LIMITS_DEFAULTS

Description:
  • Defaults when isolation.worker_limits is omitted or partial.
Defaults when isolation.worker_limits is omitted or partial.

Methods

(inner) applyAfterSpawn(child, limits, loggeropt, workerKeyopt)

Description:
  • Apply post-spawn limits (priority, Linux prlimit). Best-effort; never throws.
Parameters:
Name Type Attributes Description
child object child_process ChildProcess
limits object normalized or raw
logger object <optional>
workerKey string <optional>

(inner) applyRssLimit(pid, maxRssMb, log, tag)

Description:
  • Linux: prlimit --as=BYTES (address space). No-op on Windows / if prlimit missing.
Parameters:
Name Type Description
pid number
maxRssMb number
log object
tag string

(inner) buildWorkerEnv(baseEnv, limits, extra) → {object}

Description:
  • Build env vars for a forked worker (does not mutate process.env).
Parameters:
Name Type Description
baseEnv object usually process.env
limits object normalized worker_limits
extra object GINGEE_WORKER etc.
Returns:
Type
object

(inner) describeLimits(limits) → {string}

Description:
  • Human-readable summary for logs.
Parameters:
Name Type Description
limits object
Returns:
Type
string

(inner) mergeNodeOptions(existing, flags) → {string}

Description:
  • Merge NODE_OPTIONS flag list: later flags for the same key replace earlier ones.
Parameters:
Name Type Description
existing string
flags Array.<string> e.g. ['--max-old-space-size=512']
Returns:
Type
string

(inner) normalizePriority(p) → {string|null}

Parameters:
Name Type Description
p *
Returns:
Type
string | null

(inner) normalizeWorkerLimits(raw) → {object}

Parameters:
Name Type Description
raw object | null | undefined
Returns:
Type
object

(inner) positiveOrNull(v) → {number|null}

Parameters:
Name Type Description
v *
Returns:
Type
number | null

(inner) priorityToOsValue(priority) → {number|null}

Description:
  • Map priority name to os.setPriority value (cross-platform-ish).
Parameters:
Name Type Description
priority string
Returns:
Type
number | null