Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(proxy): pin the 768 MiB heap cap and the 2048Mi limit for the compact worst-structure load
Alfredo Lopez996d19e87ca3
diff --git a/codex-llm-proxy/test/deployManifest.test.ts b/codex-llm-proxy/test/deployManifest.test.tsindex 968cffafc..06650a6f3 100644--- a/codex-llm-proxy/test/deployManifest.test.ts+++ b/codex-llm-proxy/test/deployManifest.test.ts@@ -19,31 +19,31 @@ const CONTROL_PLANE_CONFIG = readFileSync(/** Headroom between the last in-flight request finishing and SIGKILL. */const SHUTDOWN_MARGIN_SECONDS = 20/**- * Heap cap the peak below was measured with. At 384 MiB the process aborts- * while it parses the three admitted ordinary bodies when each one carries the- * worst structure the contract admits (262144 containers, 262144 members,- * 1048576 elements), before any stream reaches the upstream. 512 MiB is the- * smallest cap that survives that load.+ * Heap cap the peak below was measured with. The byte-based BodyBudget admits+ * about eight compact bodies of the worst structure the contract admits+ * (262144 containers, 262144 members, 1048576 elements; 2.8 MiB each), and each+ * parsed tree costs about 44 MiB after a collection. With 8 held streams, 8+ * queued bodies and two visual streams, a 640 MiB cap aborted the proxy in 3 of+ * 3 runs; 768 MiB passed in 3 of 3. 768 MiB is the smallest cap tested that+ * passes, not a proven minimum.*/-const HEAP_CAP_MIB = 512+const HEAP_CAP_MIB = 768/**- * The largest measured peak, heap capped at HEAP_CAP_MIB (tsc build, one- * process, upstream request through undici, macOS, Node v24.18.0):- * - D5 (#739): eight 8 MiB streams, two 24 MiB visual streams and three- * queued 8 MiB bodies with a text tool description: 790.3 MiB at a- * 384 MiB cap;- * - the same load with every ordinary body carrying the worst structure the- * contract admits (#806 Q1): 1094.9 and 1129.2 MiB in two runs at 512.- * That is the recorded peak.- * Measured by hand, not by this suite (harness: 8 held streams, 3 queued- * bodies, 2 visual bodies). Re-measure before changing it.+ * The largest measured peak RSS, heap capped at HEAP_CAP_MIB (real proxy built+ * with tsc, upstream request through undici, macOS, Node v24.18.0, the compact+ * worst-structure shape: 8 held streams, 8 queued bodies, two visual streams).+ * Three runs: 1445.5, 1459.5 and 1327.3 MiB. The recorded peak is the maximum,+ * because the run-to-run spread on macOS is over 100 MiB and RSS there is not+ * cgroup memory. The earlier sparse-shape peak (790.3 MiB at heap 384) is+ * lower.+ * Measured by hand, not by this suite. Re-measure before changing it.*/-const D5_CAPPED_PEAK_RSS_MIB = 1129.2+const CAPPED_PEAK_RSS_MIB = 1459.5const MEMORY_HEADROOM = 1.25/**- * Owner decision on review M4 (#739): the request stays at 768Mi. It sits- * below the limit, so the scheduler reserves what the ordinary load uses and- * the worst-structure burst is covered by the limit alone.+ * The request stays at 768Mi (owner decision on review M4, #739). It sits+ * below the limit, so the scheduler reserves 768Mi while the pod can burst to+ * the limit. That burst is not reserved on the node.*/const MEMORY_REQUEST_MIB = 768@@ -96,7 +96,7 @@ describe('codex-llm-proxy base manifest', () => {expect(grace).toBe(Math.ceil(worstCaseMs / 1000) + SHUTDOWN_MARGIN_SECONDS)})- it('T-DEP-2 caps the heap below the memory limit, keeps the limit above the D5 peak and requests 768Mi', () => {+ it('T-DEP-2 caps the heap below the memory limit, keeps the limit 25% above the worst-structure peak and requests 768Mi', () => {const nodeOptions = activeLines(MANIFEST).findIndex((line) => /name:\s*NODE_OPTIONS\s*$/.test(line))expect(nodeOptions, 'the container must set NODE_OPTIONS').toBeGreaterThanOrEqual(0)const heap = /--max-old-space-size=(\d+)/.exec(activeLines(MANIFEST)[nodeOptions + 1] ?? '')@@ -106,7 +106,7 @@ describe('codex-llm-proxy base manifest', () => {expect(Number(heap![1])).toBeLessThan(limit)expect(resourceMemory('requests')).toBeLessThanOrEqual(limit)expect(resourceMemory('requests')).toBe(MEMORY_REQUEST_MIB)- expect(limit).toBeGreaterThanOrEqual(Math.ceil(D5_CAPPED_PEAK_RSS_MIB * MEMORY_HEADROOM))+ expect(limit).toBeGreaterThanOrEqual(Math.ceil(CAPPED_PEAK_RSS_MIB * MEMORY_HEADROOM))})it('T-DEP-3 keeps the Codex subscription off in base, as keyper-labs/evenfire-infra CI requires', () => {diff --git a/grok-llm-proxy/test/deployManifest.test.ts b/grok-llm-proxy/test/deployManifest.test.tsindex 3e2277025..7a55007dd 100644--- a/grok-llm-proxy/test/deployManifest.test.ts+++ b/grok-llm-proxy/test/deployManifest.test.ts@@ -24,31 +24,31 @@ const WORKFLOW_RECIPES = readFileSync(/** Headroom between the last in-flight request finishing and SIGKILL. */const SHUTDOWN_MARGIN_SECONDS = 20/**- * Heap cap the peak below was measured with. At 384 MiB the process aborts- * while it parses the three admitted ordinary bodies when each one carries the- * worst structure the contract admits (262144 containers, 262144 members,- * 1048576 elements), before any stream reaches the upstream. 512 MiB is the- * smallest cap that survives that load.+ * Heap cap the peak below was measured with. The byte-based BodyBudget admits+ * about eight compact bodies of the worst structure the contract admits+ * (262144 containers, 262144 members, 1048576 elements; 2.8 MiB each), and each+ * parsed tree costs about 44 MiB after a collection. With 8 held streams, 8+ * queued bodies and one V2 stream, a 640 MiB cap aborted the Codex proxy in 3+ * of 3 runs (Grok passed 3 of 3); 768 MiB passed both proxies in 3 of 3.+ * 768 MiB is the smallest cap tested that passes both, not a proven minimum.*/-const HEAP_CAP_MIB = 512+const HEAP_CAP_MIB = 768/**- * The largest measured peak, heap capped at HEAP_CAP_MIB (tsc build, one- * process, upstream request through undici, macOS, Node v24.18.0):- * - D5 (#739): eight 8 MiB streams and three queued 8 MiB bodies with a- * text tool description: 511 MiB at a 384 MiB cap;- * - D5 plus the visual slot (#784), same text load: 775.4 MiB at 384;- * - the same load with every ordinary body carrying the worst structure the- * contract admits (#806 Q1), plus one ~36 MB V2 stream: 1096.8 and 1110.7- * MiB in two runs at 512. That is the recorded peak.- * Measured by hand, not by this suite (harness: 8 held streams, 3 queued- * bodies, 1 visual body). Re-measure before changing it.+ * The largest measured peak RSS, heap capped at HEAP_CAP_MIB (real proxy built+ * with tsc, upstream request through undici, macOS, Node v24.18.0, the compact+ * worst-structure shape: 8 held streams, 8 queued bodies, one ~36 MB V2+ * stream). Three runs: 1357.1, 1481.6 and 1212.5 MiB. The recorded peak is the+ * maximum, because the run-to-run spread on macOS is over 100 MiB and RSS+ * there is not cgroup memory. The earlier sparse-shape peaks (511 MiB at+ * heap 384, 775.4 MiB with the visual slot) are lower.+ * Measured by hand, not by this suite. Re-measure before changing it.*/-const CAPPED_PEAK_RSS_MIB = 1110.7+const CAPPED_PEAK_RSS_MIB = 1481.6const MEMORY_HEADROOM = 1.25/**- * Owner decision on review M4 (#739): the request stays at 768Mi. It sits- * below the limit, so the scheduler reserves what the ordinary load uses and- * the worst-structure burst is covered by the limit alone.+ * The request stays at 768Mi (owner decision on review M4, #739). It sits+ * below the limit, so the scheduler reserves 768Mi while the pod can burst to+ * the limit. That burst is not reserved on the node.*/const MEMORY_REQUEST_MIB = 768@@ -101,7 +101,7 @@ describe('grok-llm-proxy base manifest', () => {expect(grace).toBe(Math.ceil(worstCaseMs / 1000) + SHUTDOWN_MARGIN_SECONDS)})- it('T-DEP-2 caps the heap below the memory limit, keeps the limit 25% above the worst-structure-plus-visual peak and requests 768Mi', () => {+ it('T-DEP-2 caps the heap below the memory limit, keeps the limit 25% above the worst-structure peak and requests 768Mi', () => {const nodeOptions = activeLines(MANIFEST).findIndex((line) => /name:\s*NODE_OPTIONS\s*$/.test(line))expect(nodeOptions, 'the container must set NODE_OPTIONS').toBeGreaterThanOrEqual(0)const heap = /--max-old-space-size=(\d+)/.exec(activeLines(MANIFEST)[nodeOptions + 1] ?? '')diff --git a/scripts/tests/test-codex-llm-proxy-deploy-contract.sh b/scripts/tests/test-codex-llm-proxy-deploy-contract.shindex 1ac340c54..8ae48829e 100755--- a/scripts/tests/test-codex-llm-proxy-deploy-contract.sh+++ b/scripts/tests/test-codex-llm-proxy-deploy-contract.sh@@ -99,24 +99,25 @@ if named_containers != ["codex-llm-proxy"]:# Measured on the shipping design (#739 D5): eight 8 MiB streams, two 24 MiB# visual streams and three queued 8 MiB bodies peaked at 790 MiB of RSS with a-# 384 MiB old space and at 886-1009 MiB without it. When the three ordinary-# bodies carry the worst structure the contract admits (#806 Q1), a 384 MiB old-# space aborts while parsing them, and a 512 MiB one is the smallest that-# survives; that load peaked at 1095-1129 MiB of RSS. The limit is that peak-# plus 25 %, rounded up to 1536Mi. The request stays at 768Mi (owner decision on-# review M4), so the scheduler reserves what the ordinary load uses and the-# worst-structure burst is covered by the limit alone.+# 384 MiB old space and at 886-1009 MiB without it. The byte-based BodyBudget+# also admits about eight compact bodies of the worst structure the contract+# admits (#806 Q1), each a ~44 MiB tree once parsed. With 8 held streams, 8+# queued bodies and two visual streams, a 640 MiB old space aborted 3 of 3 and+# 768 MiB passed 3 of 3; that load peaked at 1327-1460 MiB of RSS on macOS (not+# cgroup memory). The limit is the maximum plus 25 %, rounded up to 2048Mi. The+# request stays at 768Mi (owner decision on review M4), so the scheduler+# reserves 768Mi and the burst up to the limit is not reserved on the node.memory_limit = re.search(r"limits:\n\s+cpu: \S+\n\s+memory: (\S+)", text)memory_request = re.search(r"requests:\n\s+cpu: \S+\n\s+memory: (\S+)", text)heap_cap = re.search(r"- name: NODE_OPTIONS\n\s+value: \"--max-old-space-size=(\d+)\"", text)-if not memory_limit or memory_limit.group(1) != "1536Mi":- errors.append("proxy memory limit must be 1536Mi")+if not memory_limit or memory_limit.group(1) != "2048Mi":+ errors.append("proxy memory limit must be 2048Mi")if not memory_request or memory_request.group(1) != "768Mi":errors.append("proxy memory request must be 768Mi")-if not heap_cap or heap_cap.group(1) != "512":- errors.append("proxy must cap the V8 old space at 512 MiB through NODE_OPTIONS")+if not heap_cap or heap_cap.group(1) != "768":+ errors.append("proxy must cap the V8 old space at 768 MiB through NODE_OPTIONS")# #739 D6: on SIGTERM the proxy stops accepting and waits for its open streams# (main.ts awaits servers.close()), so the grace period must outlast thediff --git a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh b/scripts/tests/test-grok-llm-proxy-deploy-contract.shindex 099114419..1f372e3d6 100755--- a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh+++ b/scripts/tests/test-grok-llm-proxy-deploy-contract.sh@@ -87,24 +87,26 @@ if "CONTROL_API_INTERNAL_SERVICE_TOKENS" in text:# Eight 8 MiB streams and three queued 8 MiB bodies (#739 D5) peaked at 511 MiB# of RSS with a 384 MiB old space (#739 measured 509.8); one ~36 MB V2 stream in-# the visual slot (#784) raised that to 775 MiB. When the three ordinary bodies-# carry the worst structure the contract admits (#806 Q1), a 384 MiB old space-# aborts while parsing them, and a 512 MiB one is the smallest that survives;-# with one visual stream that load peaked at 1097-1111 MiB of RSS. The limit is-# that peak plus 25 %, rounded up to 1536Mi. The request stays at 768Mi (owner-# decision on review M4), so the scheduler reserves what the ordinary load uses-# and the worst-structure burst is covered by the limit alone.+# the visual slot (#784) raised that to 775 MiB. The byte-based BodyBudget also+# admits about eight compact bodies of the worst structure the contract admits+# (#806 Q1), each a ~44 MiB tree once parsed. With 8 held streams, 8 queued+# bodies and one V2 stream, a 640 MiB old space passed 3 of 3 for Grok and+# aborted 3 of 3 for Codex, and 768 MiB passed both in 3 of 3; that load peaked+# at 1212-1482 MiB of RSS on macOS (not cgroup memory). The limit is the+# maximum plus 25 %, rounded up to 2048Mi. The request stays at 768Mi (owner+# decision on review M4), so the scheduler reserves 768Mi and the burst up to+# the limit is not reserved on the node.memory_limit = re.search(r"limits:\n\s+cpu: \S+\n\s+memory: (\S+)", text)memory_request = re.search(r"requests:\n\s+cpu: \S+\n\s+memory: (\S+)", text)heap_cap = re.search(r"- name: NODE_OPTIONS\n\s+value: \"--max-old-space-size=(\d+)\"", text)-if not memory_limit or memory_limit.group(1) != "1536Mi":- errors.append("proxy memory limit must be 1536Mi")+if not memory_limit or memory_limit.group(1) != "2048Mi":+ errors.append("proxy memory limit must be 2048Mi")if not memory_request or memory_request.group(1) != "768Mi":errors.append("proxy memory request must be 768Mi")-if not heap_cap or heap_cap.group(1) != "512":- errors.append("proxy must cap the V8 old space at 512 MiB through NODE_OPTIONS")+if not heap_cap or heap_cap.group(1) != "768":+ errors.append("proxy must cap the V8 old space at 768 MiB through NODE_OPTIONS")# #739 D6: on SIGTERM the proxy stops accepting and waits for its open streams# (main.ts awaits servers.close()), so the grace period must outlast the