Improve huge selection handling#1399
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 767980a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Unified selection benchmark
| Benchmark suite | Current: 767980a | Previous: 701b08c | Deviation | Status |
|---|---|---|---|---|
compute selection for 50k elements |
386 ms |
401 ms |
-3.74% |
〰️ |
compute selection for 50k elements (P95 of main thread blocks) |
31 ms |
32 ms |
-3.13% |
〰️ |
compute parent selection for 50k elements |
345 ms |
357 ms |
-3.36% |
〰️ |
compute parent selection for 50k elements (P95 of main thread blocks) |
31 ms |
35 ms |
-11.43% |
〰️ |
compute top ancestor selection for 50k elements |
559 ms |
561 ms |
-0.36% |
〰️ |
compute top ancestor selection for 50k elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
compute category selection for 50k elements |
101 ms |
104 ms |
-2.88% |
〰️ |
compute category selection for 50k elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
compute model selection for 50k elements |
85 ms |
84 ms |
1.19% |
〰️ |
compute model selection for 50k elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
compute functional selection for 50k 3D elements |
427 ms |
443 ms |
-3.61% |
〰️ |
compute functional selection for 50k 3D elements (P95 of main thread blocks) |
34 ms |
31 ms |
9.68% |
〰️ |
compute parent functional selection for 50k 3D elements |
443 ms |
464 ms |
-4.53% |
〰️ |
compute parent functional selection for 50k 3D elements (P95 of main thread blocks) |
35 ms |
35 ms |
0% |
🟰 |
compute top ancestor functional selection for 50k 3D elements |
1173 ms |
1191 ms |
-1.51% |
〰️ |
compute top ancestor functional selection for 50k 3D elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
compute functional selection for 50k 2D elements |
2988 ms |
3037 ms |
-1.61% |
〰️ |
compute functional selection for 50k 2D elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
compute parent functional selection for 50k 2D elements |
2983 ms |
2933 ms |
1.70% |
〰️ |
compute parent functional selection for 50k 2D elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
compute top ancestor functional selection for 50k 2D elements |
3047 ms |
3072 ms |
-0.81% |
〰️ |
compute top ancestor functional selection for 50k 2D elements (P95 of main thread blocks) |
0 ms |
0 ms |
0% |
🟰 |
hilite 50k elements |
1266 ms |
1192 ms |
6.21% |
〰️ |
hilite 50k elements (P95 of main thread blocks) |
55 ms |
52 ms |
5.77% |
〰️ |
hilite 50k group elements |
240 ms |
236 ms |
1.69% |
〰️ |
hilite 50k group elements (P95 of main thread blocks) |
31 ms |
31 ms |
0% |
🟰 |
hilite 1k subjects |
46999 ms |
48341 ms |
-2.78% |
〰️ |
hilite 1k subjects (P95 of main thread blocks) |
26 ms |
28 ms |
-7.14% |
〰️ |
hilite 50k subcategories |
310 ms |
315 ms |
-1.59% |
〰️ |
hilite 50k subcategories (P95 of main thread blocks) |
39 ms |
39 ms |
0% |
🟰 |
hilite 50k functional 3D elements |
31446 ms |
29150 ms |
7.88% |
〰️ |
hilite 50k functional 3D elements (P95 of main thread blocks) |
41 ms |
41 ms |
0% |
🟰 |
hilite 50k functional 2D elements |
6678 ms |
6329 ms |
5.51% |
〰️ |
hilite 50k functional 2D elements (P95 of main thread blocks) |
43 ms |
41 ms |
4.88% |
〰️ |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses performance issues when unified selection contains a very large number of elements by avoiding unnecessary instance-key materialization and by yielding during large instance-key loads to reduce main-thread blocking.
Changes:
- Updated
usePropertyDataProviderWithUnifiedSelectionto short-circuit selection handling when selection size exceeds the configured limit (avoid creating/loading a fullKeySet). - Updated
Selectables.loadto periodically yield while iterating large instance-key sets to reduce UI freezing. - Added changesets for
@itwin/unified-selectionand@itwin/presentation-components.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/unified-selection/src/unified-selection/Selectable.ts | Adds main-thread yielding while iterating large instanceKeys selections during Selectables.load. |
| packages/components/src/presentation-components/propertygrid/UseUnifiedSelection.tsx | Avoids materializing KeySet from storage when selection is over limit; propagates either KeySet or size. |
| .changeset/hip-spoons-tease.md | Changeset for @itwin/unified-selection performance improvement. |
| .changeset/common-frogs-dig.md | Changeset for @itwin/presentation-components selection-limit optimization. |
grigasp
approved these changes
Jun 15, 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.
Closes #1398
Updated
usePropertyDataProviderWithUnifiedSelectionto avoid loading instance keys when selection is huge and exceeds limit.Updated
Selectables.loadto avoid freezing main thread when loading huge selection.