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

推荐订阅源

H
Help Net Security
宝玉的分享
宝玉的分享
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
Visual Studio Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
P
Proofpoint News Feed
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
博客园 - 【当耐特】
Martin Fowler
Martin Fowler

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(perf): harden gateway restart bench exits · openclaw/...
vincentkoc · 2026-05-25 · via Recent Commits to openclaw:main

@@ -68,6 +68,15 @@ type GatewayRestartFailureCode =

6868

| "child_nonzero_exit"

6969

| "cleanup_failed";

707071+

type ChildExit = {

72+

exitCode: number | null;

73+

signal: string | null;

74+

};

75+76+

type StopChildResult = ChildExit & {

77+

exitedBeforeTeardown: boolean;

78+

};

79+7180

type RestartIteration = {

7281

cpuCoreRatio: number | null;

7382

cpuMs: number | null;

@@ -98,6 +107,7 @@ type GatewayRestartSample = {

98107

childExitCode: number | null;

99108

childSignal: string | null;

100109

events: BenchmarkEvent[];

110+

exitedBeforeTeardown: boolean;

101111

failureCode: GatewayRestartFailureCode | null;

102112

firstOutputMs: number | null;

103113

initialGatewayReadyLogLine: string | null;

@@ -869,36 +879,52 @@ function writeRestartIntent(env: NodeJS.ProcessEnv, targetPid: number, reason: s

869879

}

870880

}

871881872-

async function stopChild(child: ChildProcessWithoutNullStreams): Promise<{

873-

exitCode: number | null;

874-

signal: string | null;

875-

}> {

876-

if (child.exitCode != null || child.signalCode != null) {

877-

return { exitCode: child.exitCode, signal: child.signalCode };

882+

async function stopChild(child: ChildProcessWithoutNullStreams): Promise<StopChildResult> {

883+

const currentExit = (): ChildExit | null =>

884+

child.exitCode != null || child.signalCode != null

885+

? { exitCode: child.exitCode, signal: child.signalCode }

886+

: null;

887+888+

const existingExit = currentExit();

889+

if (existingExit != null) {

890+

return { ...existingExit, exitedBeforeTeardown: true };

878891

}

879-

const exited = new Promise<{ exitCode: number | null; signal: string | null }>((resolve) => {

880-

child.once("exit", (exitCode, signal) => resolve({ exitCode, signal }));

892+893+

let observedExit: ChildExit | null = null;

894+

const exited = new Promise<ChildExit>((resolve) => {

895+

child.once("exit", (exitCode, signal) => {

896+

observedExit = { exitCode, signal };

897+

resolve(observedExit);

898+

});

881899

});

882-

killProcessTree(child, "SIGTERM");

900+901+

await new Promise<void>((resolve) => setImmediate(resolve));

902+

const queuedExit = observedExit ?? currentExit();

903+

if (queuedExit != null) {

904+

return { ...queuedExit, exitedBeforeTeardown: true };

905+

}

906+907+

const sentTeardownSignal = killProcessTree(child, "SIGTERM");

883908

const timeout = delay(2000).then(() => {

884909

if (child.exitCode == null && child.signalCode == null) {

885910

killProcessTree(child, "SIGKILL");

886911

}

887912

return exited;

888913

});

889-

return Promise.race([exited, timeout]);

914+

const exit = await Promise.race([exited, timeout]);

915+

return { ...exit, exitedBeforeTeardown: !sentTeardownSignal };

890916

}

891917892-

function killProcessTree(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals): void {

918+

function killProcessTree(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals): boolean {

893919

if (process.platform !== "win32" && child.pid !== undefined) {

894920

try {

895921

process.kill(-child.pid, signal);

896-

return;

922+

return true;

897923

} catch {

898924

// Fall back to the direct child below.

899925

}

900926

}

901-

child.kill(signal);

927+

return child.kill(signal);

902928

}

903929904930

function readProcessRssMb(pid: number | undefined): number | null {

@@ -1197,6 +1223,15 @@ function resolveRestartDeadlineFailure(childExited: boolean): GatewayRestartFail

11971223

return childExited ? "restart_child_exited" : "restart_deadline_timeout";

11981224

}

119912251226+

function resolveSampleExitFailure(exit: StopChildResult): GatewayRestartFailureCode | null {

1227+

if (!exit.exitedBeforeTeardown) {

1228+

return null;

1229+

}

1230+

return exit.exitCode !== null && exit.exitCode !== 0

1231+

? "child_nonzero_exit"

1232+

: "restart_child_exited";

1233+

}

1234+12001235

function computeResourceSlope(iterations: RestartIteration[]): ResourceSlope {

12011236

return {

12021237

activeHandlesCountPerRestart: slope(

@@ -1528,9 +1563,7 @@ async function runGatewaySample(options: {

15281563

flushOutputLineBuffers(outputBuffers, onLine, performance.now() - sampleStartAt, {

15291564

flushPartial: true,

15301565

});

1531-

if (exit.exitCode !== null && exit.exitCode !== 0 && failureCode === null) {

1532-

failureCode = "child_nonzero_exit";

1533-

}

1566+

failureCode ??= resolveSampleExitFailure(exit);

15341567

try {

15351568

rmSync(root, { force: true, maxRetries: 3, recursive: true, retryDelay: 100 });

15361569

} catch {

@@ -1541,6 +1574,7 @@ async function runGatewaySample(options: {

15411574

childExitCode: exit.exitCode,

15421575

childSignal: exit.signal,

15431576

events,

1577+

exitedBeforeTeardown: exit.exitedBeforeTeardown,

15441578

failureCode,

15451579

firstOutputMs,

15461580

initialGatewayReadyLogLine,

@@ -1693,8 +1727,10 @@ export const testing = {

16931727

resolveRestartDeadlineFailure,

16941728

resolveEntry,

16951729

resolvePhaseDeadlineAt,

1730+

resolveSampleExitFailure,

16961731

sanitizedEnv,

16971732

shouldFailBenchmark,

1733+

stopChild,

16981734

summarizeCase,

16991735

waitForRestartProbe,

17001736

writeConfig,