Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-paws-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@langchain/langgraph": patch
---

Improve tick performance by calling `maxChannelMapVersion` only once
6 changes: 5 additions & 1 deletion libs/langgraph/src/pregel/algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand All @@ -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
Expand Down
Loading