Conversation
OEvgeny
commented
Mar 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Improves ActivityKeyerComposer key assignment performance during streaming/append-heavy updates by adding an incremental “append-only” fast path that avoids full rescans, while retaining a full recompute fallback for reorder/removal scenarios.
Changes:
- Added common-prefix detection and an append-only incremental update path to process only newly appended activities.
- Switched the internal key maps to mutable
Maps held in refs to support in-place incremental updates. - Updated the changelog with an entry describing the performance improvement.
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 | Adds append-only incremental keying logic with ref-held mutable maps and a slow-path full recompute fallback. |
| CHANGELOG.md | Documents the performance improvement in ActivityKeyerComposer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
compulim
approved these changes
Mar 27, 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, by @OEvgenyDescription
ActivityKeyerComposerre-iterated all activities on every render to assign stable keys. With 1000+ streaming delta activities, each push triggered a full O(n) scan, making overall complexity growing towards O(n²) if we push fast enough. This PR adds an incremental fast path so only newly-appended activities are processed per render.This implies that activities are immutable.
Design
The
useMemonow uses a two-path strategy:This is still iterating the whole array, but since we need only ref checks, we spend only about 10% of the previous time on this work.
Specific Changes
prevActivitiesRefandprevActivityKeysStateRefrefs to track previous render stateactivities[commonPrefixLength..]Object.freezeonMapinstances) so the fast path can append in-placeactivitiesvariable toactivitiesForKeyinkeyToActivitiesMapconstructionI have updated documentation