惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
J
Java Code Geeks
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
L
LangChain Blog
WordPress大学
WordPress大学
A
About on SuperTechFans
Martin Fowler
Martin Fowler
月光博客
月光博客
Y
Y Combinator Blog
U
Unit 42
D
Docker
Recent Announcements
Recent Announcements
Hugging Face - Blog
Hugging Face - Blog
B
Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(test): harden Docker resource ceilings · openclaw/ope...
vincentkoc · 2026-05-24 · via Recent Commits to openclaw:main

@@ -4,17 +4,29 @@ const [statsFile, maxMemoryRaw, maxCpuRaw, label = "docker"] = process.argv.slic

44

const maxMemoryMiB = Number(maxMemoryRaw);

55

const maxCpuPercent = Number(maxCpuRaw);

667+

function assertFiniteLimit(value, raw, name) {

8+

if (!Number.isFinite(value) || value < 0) {

9+

throw new Error(`${name} must be a finite non-negative number. Got: ${JSON.stringify(raw)}`);

10+

}

11+

}

12+713

function parseMemoryMiB(raw) {

814

const value =

915

String(raw || "")

1016

.split("/")[0]

1117

?.trim() || "";

1218

const match = /^([0-9.]+)\s*([KMGT]?i?B)$/iu.exec(value);

1319

if (!match) {

14-

return 0;

20+

return undefined;

1521

}

1622

const amount = Number(match[1]);

23+

if (!Number.isFinite(amount)) {

24+

return undefined;

25+

}

1726

const unit = match[2].toLowerCase();

27+

if (unit === "b") {

28+

return amount / 1024 / 1024;

29+

}

1830

if (unit === "kb" || unit === "kib") {

1931

return amount / 1024;

2032

}

@@ -27,33 +39,52 @@ function parseMemoryMiB(raw) {

2739

if (unit === "tb" || unit === "tib") {

2840

return amount * 1024 * 1024;

2941

}

30-

return 0;

42+

return undefined;

43+

}

44+45+

function parseCpuPercent(raw) {

46+

const parsed = Number(String(raw || "").replace(/%$/u, ""));

47+

return Number.isFinite(parsed) ? parsed : undefined;

48+

}

49+50+

function assertSampleValue(value, raw, name, label) {

51+

if (value === undefined) {

52+

throw new Error(

53+

`docker stats sample for ${label} had invalid ${name}: ${JSON.stringify(raw)}`,

54+

);

55+

}

3156

}

32573358

const lines = fs.existsSync(statsFile)

3459

? fs.readFileSync(statsFile, "utf8").split(/\r?\n/u).filter(Boolean)

3560

: [];

3661

let maxObservedMemoryMiB = 0;

3762

let maxObservedCpuPercent = 0;

63+

let parsedSamples = 0;

64+65+

assertFiniteLimit(maxMemoryMiB, maxMemoryRaw, "max memory MiB");

66+

assertFiniteLimit(maxCpuPercent, maxCpuRaw, "max CPU percent");

38673968

for (const line of lines) {

4069

let parsed;

4170

try {

4271

parsed = JSON.parse(line);

4372

} catch {

44-

continue;

73+

throw new Error(`docker stats sample for ${label} was not valid JSON`);

4574

}

46-

maxObservedMemoryMiB = Math.max(maxObservedMemoryMiB, parseMemoryMiB(parsed.MemUsage));

47-

maxObservedCpuPercent = Math.max(

48-

maxObservedCpuPercent,

49-

Number(String(parsed.CPUPerc || "0").replace(/%$/u, "")) || 0,

50-

);

75+

const observedMemoryMiB = parseMemoryMiB(parsed.MemUsage);

76+

const observedCpuPercent = parseCpuPercent(parsed.CPUPerc);

77+

assertSampleValue(observedMemoryMiB, parsed.MemUsage, "MemUsage", label);

78+

assertSampleValue(observedCpuPercent, parsed.CPUPerc, "CPUPerc", label);

79+

parsedSamples += 1;

80+

maxObservedMemoryMiB = Math.max(maxObservedMemoryMiB, observedMemoryMiB);

81+

maxObservedCpuPercent = Math.max(maxObservedCpuPercent, observedCpuPercent);

5182

}

52835384

console.log(

54-

`${label} resource peak: memory=${maxObservedMemoryMiB.toFixed(1)}MiB cpu=${maxObservedCpuPercent.toFixed(1)}% samples=${lines.length}`,

85+

`${label} resource peak: memory=${maxObservedMemoryMiB.toFixed(1)}MiB cpu=${maxObservedCpuPercent.toFixed(1)}% samples=${parsedSamples}`,

5586

);

56-

if (lines.length === 0) {

87+

if (parsedSamples === 0) {

5788

throw new Error(`no docker stats samples captured for ${label}`);

5889

}

5990

if (maxObservedMemoryMiB > maxMemoryMiB) {