mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 09:02:15 +00:00
perf: reduce plugin and memory startup overhead
This commit is contained in:
@@ -94,6 +94,12 @@ function shouldIgnoreMemoryWatchPath(watchPath: string): boolean {
|
||||
return parts.some((segment) => IGNORED_MEMORY_WATCH_DIR_NAMES.has(segment));
|
||||
}
|
||||
|
||||
export function runDetachedMemorySync(sync: () => Promise<void>, reason: "interval" | "watch") {
|
||||
void sync().catch((err) => {
|
||||
log.warn(`memory sync failed (${reason}): ${String(err)}`);
|
||||
});
|
||||
}
|
||||
|
||||
export abstract class MemoryManagerSyncOps {
|
||||
protected abstract readonly cfg: OpenClawConfig;
|
||||
protected abstract readonly agentId: string;
|
||||
@@ -650,9 +656,7 @@ export abstract class MemoryManagerSyncOps {
|
||||
}
|
||||
const ms = minutes * 60 * 1000;
|
||||
this.intervalTimer = setInterval(() => {
|
||||
void this.sync({ reason: "interval" }).catch((err) => {
|
||||
log.warn(`memory sync failed (interval): ${String(err)}`);
|
||||
});
|
||||
runDetachedMemorySync(() => this.sync({ reason: "interval" }), "interval");
|
||||
}, ms);
|
||||
}
|
||||
|
||||
@@ -665,9 +669,7 @@ export abstract class MemoryManagerSyncOps {
|
||||
}
|
||||
this.watchTimer = setTimeout(() => {
|
||||
this.watchTimer = null;
|
||||
void this.sync({ reason: "watch" }).catch((err) => {
|
||||
log.warn(`memory sync failed (watch): ${String(err)}`);
|
||||
});
|
||||
runDetachedMemorySync(() => this.sync({ reason: "watch" }), "watch");
|
||||
}, this.settings.sync.watchDebounceMs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user