mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-22 17:15:25 -04:00
perf(langgraph): avoid calling maxChannelMapVersion twice (#1622)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@langchain/langgraph": patch
|
||||
---
|
||||
|
||||
Improve tick performance by calling `maxChannelMapVersion` only once
|
||||
@@ -272,10 +272,12 @@ export function _applyWrites<Cc extends Record<string, BaseChannel>>(
|
||||
.filter((chan) => !RESERVED.includes(chan))
|
||||
);
|
||||
|
||||
let usedNewVersion = false;
|
||||
for (const chan of channelsToConsume) {
|
||||
if (chan in onlyChannels && onlyChannels[chan].consume()) {
|
||||
if (getNextVersion !== undefined) {
|
||||
checkpoint.channel_versions[chan] = getNextVersion(maxVersion);
|
||||
usedNewVersion = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +296,9 @@ export function _applyWrites<Cc extends Record<string, BaseChannel>>(
|
||||
}
|
||||
|
||||
// Find the highest version of all channels
|
||||
maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
|
||||
if (maxVersion != null && getNextVersion != null) {
|
||||
maxVersion = usedNewVersion ? getNextVersion(maxVersion) : maxVersion;
|
||||
}
|
||||
|
||||
const updatedChannels: Set<string> = new Set();
|
||||
// Apply writes to channels
|
||||
|
||||
Reference in New Issue
Block a user