perf: reduce gateway cpu churn · openclaw/openclaw@a43da0c
steipete
·
2026-05-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2556,7 +2556,7 @@ export async function runCodexAppServerAttempt(
|
2556 | 2556 | threadId: thread.threadId, |
2557 | 2557 | ...(turnId ? { turnId } : {}), |
2558 | 2558 | }); |
2559 | | -embeddedAgentLog.debug("codex app-server raw notification received", correlation); |
| 2559 | +embeddedAgentLog.trace("codex app-server raw notification received", correlation); |
2560 | 2560 | if (notification.method === "turn/completed" && correlation.matchesActiveTurn === false) { |
2561 | 2561 | if (correlation.matchesActiveThread) { |
2562 | 2562 | embeddedAgentLog.warn( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,6 +31,18 @@ function debugSkillCommandOnce(
|
31 | 31 | skillsLogger.debug(message, meta); |
32 | 32 | } |
33 | 33 | |
| 34 | +function traceSkillCommandOnce( |
| 35 | +messageKey: string, |
| 36 | +message: string, |
| 37 | +meta?: Record<string, unknown>, |
| 38 | +) { |
| 39 | +if (skillCommandDebugOnce.has(messageKey)) { |
| 40 | +return; |
| 41 | +} |
| 42 | +skillCommandDebugOnce.add(messageKey); |
| 43 | +skillsLogger.trace(message, meta); |
| 44 | +} |
| 45 | + |
34 | 46 | function sanitizeSkillCommandName(raw: string): string { |
35 | 47 | const normalized = normalizeLowercaseStringOrEmpty(raw) |
36 | 48 | .replace(/[^a-z0-9_]+/g, "_") |
@@ -97,15 +109,15 @@ export function buildWorkspaceSkillCommandSpecs(
|
97 | 109 | const rawName = entry.skill.name; |
98 | 110 | const base = sanitizeSkillCommandName(rawName); |
99 | 111 | if (base !== rawName) { |
100 | | -debugSkillCommandOnce( |
| 112 | +traceSkillCommandOnce( |
101 | 113 | `sanitize:${rawName}:${base}`, |
102 | 114 | `Sanitized skill command name "${rawName}" to "/${base}".`, |
103 | 115 | { rawName, sanitized: `/${base}` }, |
104 | 116 | ); |
105 | 117 | } |
106 | 118 | const unique = resolveUniqueSkillCommandName(base, used); |
107 | 119 | if (unique !== base) { |
108 | | -debugSkillCommandOnce( |
| 120 | +traceSkillCommandOnce( |
109 | 121 | `dedupe:${rawName}:${unique}`, |
110 | 122 | `De-duplicated skill command name for "${rawName}" to "/${unique}".`, |
111 | 123 | { rawName, deduped: `/${unique}` }, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -529,6 +529,23 @@ describe("session store writer queue", () => {
|
529 | 529 | writeSpy.mockRestore(); |
530 | 530 | }); |
531 | 531 | |
| 532 | +it("caches unchanged session stores from persisted JSON shape", async () => { |
| 533 | +const key = "agent:main:no-op-cache"; |
| 534 | +const { storePath } = await makeTmpStore({ |
| 535 | +[key]: { sessionId: "s-noop-cache", updatedAt: Date.now() }, |
| 536 | +}); |
| 537 | + |
| 538 | +await updateSessionStore( |
| 539 | +storePath, |
| 540 | +async (store) => { |
| 541 | +(store[key] as Record<string, unknown>).ephemeral = undefined; |
| 542 | +}, |
| 543 | +{ skipMaintenance: true }, |
| 544 | +); |
| 545 | + |
| 546 | +expect(loadSessionStore(storePath)[key]).not.toHaveProperty("ephemeral"); |
| 547 | +}); |
| 548 | + |
532 | 549 | it("keeps session store writes atomic while skipping durable fsync inside the writer lock", async () => { |
533 | 550 | const key = "agent:main:no-fsync"; |
534 | 551 | const { storePath } = await makeTmpStore({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -385,7 +385,9 @@ export function writeSessionStoreCache(params: {
|
385 | 385 | takeOwnership?: boolean; |
386 | 386 | }): void { |
387 | 387 | const store = |
388 | | -params.takeOwnership === true ? params.store : cloneSessionStoreRecord(params.store); |
| 388 | +params.takeOwnership === true |
| 389 | + ? params.store |
| 390 | + : cloneSessionStoreRecord(params.store, params.serialized); |
389 | 391 | if (params.takeOwnership === true) { |
390 | 392 | internSessionStoreLargeStrings(store); |
391 | 393 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -97,6 +97,7 @@ const DEFAULT_REDACT_PATTERNS: string[] = [
|
97 | 97 | String.raw`\bbot(\d{6,}:[A-Za-z0-9_-]{20,})\b`, |
98 | 98 | String.raw`\b(\d{6,}:[A-Za-z0-9_-]{20,})\b`, |
99 | 99 | ]; |
| 100 | +let defaultResolvedPatterns: RegExp[] | undefined; |
100 | 101 | |
101 | 102 | export type RedactOptions = { |
102 | 103 | mode?: RedactSensitiveMode; |
@@ -136,8 +137,13 @@ function parsePattern(raw: RedactPattern): RegExp | null {
|
136 | 137 | } |
137 | 138 | |
138 | 139 | function resolvePatterns(value?: RedactPattern[]): RegExp[] { |
139 | | -const source = value?.length ? value : DEFAULT_REDACT_PATTERNS; |
140 | | -return source.map(parsePattern).filter((re): re is RegExp => Boolean(re)); |
| 140 | +if (!value?.length) { |
| 141 | +defaultResolvedPatterns ??= DEFAULT_REDACT_PATTERNS.map(parsePattern).filter( |
| 142 | +(re): re is RegExp => Boolean(re), |
| 143 | +); |
| 144 | +return defaultResolvedPatterns; |
| 145 | +} |
| 146 | +return value.map(parsePattern).filter((re): re is RegExp => Boolean(re)); |
141 | 147 | } |
142 | 148 | |
143 | 149 | function maskToken(token: string): string { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。