Skip to content

[Tree widget]: adjust ChildElementsCache on next#1682

Merged
JonasDov merged 18 commits into
tree-widget/nextfrom
JonasD/batching-cache
May 19, 2026
Merged

[Tree widget]: adjust ChildElementsCache on next#1682
JonasDov merged 18 commits into
tree-widget/nextfrom
JonasD/batching-cache

Conversation

@JonasDov
Copy link
Copy Markdown
Contributor

Follow up on #1681.
Adding changes from #1678 for ChildElementsCache

Copilot AI review requested due to automatic review settings May 18, 2026 15:37
@JonasDov JonasDov requested review from a team as code owners May 18, 2026 15:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR follows up on prior “next” tree-widget batching work by rewriting ChildElementsCache to use the shared BatchingCache infrastructure and updating tree visibility handlers/helpers to use the new getChildElements/getDescendantsCounts APIs instead of building a full children tree per request.

Changes:

  • Replaced ChildElementsCache implementation with a BatchingCache-based, 20ms-batched cache keyed by (modelId, parentElementId/categoryId, childCategoryIds).
  • Updated models/categories/classifications visibility handlers and helpers to fetch descendant category IDs via getDescendantsCounts and then fetch descendants via getChildElements.
  • Added a comprehensive ChildElementsCache test suite and adjusted test mocks to reflect the new API surface.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/itwin/tree-widget/src/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.ts Switch grouped-element visibility changes to the new descendant-counts + child-elements flow.
packages/itwin/tree-widget/src/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.ts Replace getChildElementsTree usage with getDescendantsCounts + getChildElements batching path.
packages/itwin/tree-widget/src/tree-widget-react/components/trees/common/internal/caches/ChildElementsCache.ts Rewrite cache to extend BatchingCache and query descendants grouped by child category.
packages/itwin/tree-widget/src/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.ts Remove tree-based child APIs and re-export getChildElements; broaden getElementsCount args.
packages/itwin/tree-widget/src/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.ts Update element visibility change logic to new cache APIs.
packages/itwin/tree-widget/src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.ts Update category visibility changes to fetch descendants via new cache APIs.
packages/itwin/tree-widget/src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.ts Update search-target element visibility logic to new cache APIs.
packages/itwin/tree-widget/src/test/trees/models-tree/Utils.ts Adjust fake ids-cache mock surface for new methods (needs further fix for new getElementsCount calls).
packages/itwin/tree-widget/src/test/trees/common/internal/ChildElementsCache.test.ts New test suite covering batching, caching, and query behavior for ChildElementsCache.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/itwin/tree-widget/src/test/trees/models-tree/Utils.ts Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tree-Widget Next benchmark

Benchmark suite Current: 95acaba Previous: 36f8841 Deviation Status
models tree 50k 3D elements search > get search paths 1266 ms 914 ms 38.51% 🚨
models tree 50k 3D elements search > get search paths (P95 of main thread blocks) 59 ms 49 ms 20.41% 〰️
models tree 50k 3D elements search > load hierarchy from search paths 110859 ms 96550 ms 14.82% 🚨
models tree 50k 3D elements search > load hierarchy from search paths (P95 of main thread blocks) 38 ms 32 ms 18.75% 〰️
models tree 50k categories > collect nodes 2883 ms 2360 ms 22.16% 🚨
models tree 50k categories > collect nodes (P95 of main thread blocks) 144 ms 83 ms 73.49% 🚨
models tree 50k categories > validate initial visibility 2508 ms 2058 ms 21.87% 🚨
models tree 50k categories > validate initial visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k categories > change visibility 76 ms 67 ms 13.43% 〰️
models tree 50k categories > change visibility (P95 of main thread blocks) 66 ms 57 ms 15.79% 〰️
models tree 50k categories > validate changed visibility 4662 ms 3903 ms 19.45% 🚨
models tree 50k categories > validate changed visibility (P95 of main thread blocks) 25 ms 0 ms 2500% 〰️
models tree 50k 3D elements > collect nodes 44424 ms 37646 ms 18.00% 🚨
models tree 50k 3D elements > collect nodes (P95 of main thread blocks) 70 ms 45 ms 55.56% 〰️
models tree 50k 3D elements > validate initial visibility 2574 ms 2081 ms 23.69% 🚨
models tree 50k 3D elements > validate initial visibility (P95 of main thread blocks) 28 ms 0 ms 2800% 〰️
models tree 50k 3D elements > change model visibility 24 ms 17 ms 41.18% 〰️
models tree 50k 3D elements > change model visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k 3D elements > validate changed model visibility 2469 ms 2103 ms 17.40% 🚨
models tree 50k 3D elements > validate changed model visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k 3D elements > change category node visibility 522 ms 421 ms 23.99% 🚨
models tree 50k 3D elements > change category node visibility (P95 of main thread blocks) 63 ms 52 ms 21.15% 〰️
models tree 50k 3D elements > validate changed category visibility 2463 ms 2065 ms 19.27% 🚨
models tree 50k 3D elements > validate changed category visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k 3D elements > validate per-model category override 2455 ms 2054 ms 19.52% 🚨
models tree 50k 3D elements > validate per-model category override (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k 3D elements > change element visibility 54 ms 10 ms 440.00% 〰️
models tree 50k 3D elements > change element visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k 3D elements > validate changed element visibility 3207 ms 2566 ms 24.98% 🚨
models tree 50k 3D elements > validate changed element visibility (P95 of main thread blocks) 68 ms 47 ms 44.68% 〰️
models tree 50k 3D child elements with different categories > collect nodes 44772 ms 37804 ms 18.43% 🚨
models tree 50k 3D child elements with different categories > collect nodes (P95 of main thread blocks) 70 ms 42 ms 66.67% 〰️
models tree 50k 3D child elements with different categories > validate initial visibility 2456 ms 2121 ms 15.79% 🚨
models tree 50k 3D child elements with different categories > validate initial visibility (P95 of main thread blocks) 0 ms 22 ms -100% 〰️
models tree 50k 3D child elements with different categories > change visibility 45 ms 11 ms 309.09% 〰️
models tree 50k 3D child elements with different categories > change visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
models tree 50k 3D child elements with different categories > validate changed visibility 3273 ms 2570 ms 27.35% 🚨
models tree 50k 3D child elements with different categories > validate changed visibility (P95 of main thread blocks) 63 ms 50 ms 26% 〰️
categories tree 50k subCategories search > get search paths 1829 ms 1402 ms 30.46% 🚨
categories tree 50k subCategories search > get search paths (P95 of main thread blocks) 42 ms 31 ms 35.48% 〰️
categories tree 50k subCategories search > load hierarchy from search paths 5357 ms 4186 ms 27.97% 🚨
categories tree 50k subCategories search > load hierarchy from search paths (P95 of main thread blocks) 49 ms 32 ms 53.13% 〰️
categories tree 50k subCategories > collect nodes 5918 ms 4575 ms 29.36% 🚨
categories tree 50k subCategories > collect nodes (P95 of main thread blocks) 47 ms 34 ms 38.24% 〰️
categories tree 50k subCategories > validate initial visibility 1665 ms 1431 ms 16.35% 🚨
categories tree 50k subCategories > validate initial visibility (P95 of main thread blocks) 21 ms 0 ms 2100% 〰️
categories tree 50k subCategories > change visibility 340 ms 326 ms 4.29% 〰️
categories tree 50k subCategories > change visibility (P95 of main thread blocks) 24 ms 0 ms 2400% 〰️
categories tree 50k subCategories > validate changed visibility 1581 ms 1370 ms 15.40% 🚨
categories tree 50k subCategories > validate changed visibility (P95 of main thread blocks) 26 ms 21 ms 23.81% 〰️
categories tree 50k categories > collect nodes 2472 ms 1973 ms 25.29% 🚨
categories tree 50k categories > collect nodes (P95 of main thread blocks) 116 ms 102 ms 13.73% 〰️
categories tree 50k categories > validate initial visibility 7206 ms 6173 ms 16.73% 🚨
categories tree 50k categories > validate initial visibility (P95 of main thread blocks) 85 ms 70 ms 21.43% 〰️
categories tree 50k categories > change visibility 669 ms 617 ms 8.43% 〰️
categories tree 50k categories > change visibility (P95 of main thread blocks) 49 ms 35 ms 40% 〰️
categories tree 50k categories > validate changed visibility 7168 ms 6106 ms 17.39% 🚨
categories tree 50k categories > validate changed visibility (P95 of main thread blocks) 31 ms 30 ms 3.33% 〰️
classifications tree 50k classifications search > get search paths 2225 ms 1635 ms 36.09% 🚨
classifications tree 50k classifications search > get search paths (P95 of main thread blocks) 133 ms 96 ms 38.54% 〰️
classifications tree 50k classifications search > load hierarchy from search paths 67728 ms 58273 ms 16.23% 🚨
classifications tree 50k classifications search > load hierarchy from search paths (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
classifications tree 50k classifications > collect nodes 36596 ms 29155 ms 25.52% 🚨
classifications tree 50k classifications > collect nodes (P95 of main thread blocks) 86 ms 59 ms 45.76% 〰️
classifications tree 50k classifications > validate initial visibility 4652 ms 3833 ms 21.37% 🚨
classifications tree 50k classifications > validate initial visibility (P95 of main thread blocks) 49 ms 65 ms -24.62% 〰️
classifications tree 50k classifications > change visibility 29 ms 25 ms 16% 〰️
classifications tree 50k classifications > change visibility (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
classifications tree 50k classifications > validate changed visibility 4858 ms 4011 ms 21.12% 🚨
classifications tree 50k classifications > validate changed visibility (P95 of main thread blocks) 65 ms 54 ms 20.37% 〰️

This comment was automatically generated by workflow using github-action-benchmark.

Comment thread packages/itwin/tree-widget/src/test/trees/models-tree/Utils.ts Outdated
@JonasDov JonasDov merged commit 598136e into tree-widget/next May 19, 2026
11 checks passed
@JonasDov JonasDov deleted the JonasD/batching-cache branch May 19, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants