perf: reduce iterations in the fast path for the keyer composer updates#5797
Merged
perf: reduce iterations in the fast path for the keyer composer updates#5797
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves ActivityKeyerComposer’s incremental (append-only) keying path by reducing per-render reference comparisons via a “frozen window” approach, and adds a deferred idle-time verification to detect unexpected mutations outside the window.
Changes:
- Introduces a frozen-window optimization that only compares the last 1,000 activities by reference on each render.
- Adds a deferred (10s quiet period +
requestIdleCallback) verification step that warns if older (“frozen”) activities changed unexpectedly. - Refactors the fast-path append branch to early-return when no new keys are created.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/api/src/providers/ActivityKeyer/ActivityKeyerComposer.tsx | Implements frozen-window fast path, deferred verification, and fast-path refactor. |
| CHANGELOG.md | Documents the performance improvement and frozen-window optimization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/api/src/providers/ActivityKeyer/ActivityKeyerComposer.tsx
Outdated
Show resolved
Hide resolved
…y with content changes Agent-Logs-Url: https://github.com/microsoft/BotFramework-WebChat/sessions/d07bf01e-33c1-440a-a28e-095207d61357 Co-authored-by: OEvgeny <2841858+OEvgeny@users.noreply.github.com>
compulim
previously approved these changes
Apr 8, 2026
Contributor
compulim
left a comment
There was a problem hiding this comment.
This is good. Will be even better if we have tests to show what happen after mutating beyond the last 1,000 activities.
compulim
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
ActivityKeyerComposerperformance for append scenarios by adding an incremental fast path that only processes newly-appended activities, in PR #5790, in PR #5797, by @OEvgenyDescription
Building on the incremental keying fast path from #5790, this PR introduces a "frozen window" optimization that skips reference comparisons for older activities. Instead of comparing every activity reference on each render, only the last 1,000 activities are checked for the frozen prefix. A deferred verification runs after 10 seconds of inactivity to warn if any frozen activity was unexpectedly mutated.
Design
MUTABLE_ACTIVITY_WINDOWconstant (1,000) defines how many trailing activities are compared reference-by-reference each render. Activities before this boundary are assumed stable.FROZEN_CHECK_TIMEOUT(10,000 ms) triggers a deferred check usingrequestIdleCallback(via ponyfill) to validate the frozen assumption and emit console warnings per position if violated.Specific Changes
FROZEN_CHECK_TIMEOUTandMUTABLE_ACTIVITY_WINDOWconstants toActivityKeyerComposer.tsxfrozenBoundary(max(0, min(prev, current) - 1000)) instead of 0useEffectwithsetTimeout+requestIdleCallbackto verify frozen portion after quiet periodpendingFrozenCheckRefandwarnedPositionsRefto track deferred check stateCHANGELOG.mdI have updated documentationReview Checklist
z-index)package.jsonandpackage-lock.jsonreviewed