You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance enhancements: startup and visualization toggles - #303
Five independent fixes to the comparison startup and interaction paths. Measured against a ~10 GB iModel and a 3+ million element comparison result (860 MB full / 265 MB property-less payload).
Changes
ModelsCategoryCache: stop querying the model of every updated element when results already carry modelId.
ChangedElementEntryCache: replace full-cache scans in getEntries / per-model lookups with Map lookups and a modelId → ids index, this enhances the performance of the tree provider and visualization.
VersionCompareTiles: build secondary-iModel overrides lazily (once per invalidation instead of twice per filter change) and partition entries by opcode once instead of on every pass.
parseJsonResponse: use native JSON.parse for identity-encoded payloads under the 256 MiB property threshold; keep the incremental parser for larger or encoded bodies.
ChangedElementsManager: release the raw accumulated change Map after entries are generated; the entry cache is the single source of truth.
Benchmark
Stage
Before
After
ModelsCategoryCache.load
46.4 s
0.9 s
getEntries(1 id) × 20
6.5 s
< 1 ms
getChangeElementIdsFromModelId × 10
2.5 s
< 1 ms
Expand largest model node (~275 k elements)
13.4 s
6.1 s
Provider.addFeatureOverrides
2.3 s
1.0 s
Filter toggle (override rebuild)
8.0 s
4.6 s
Retained heap after initialize
830 MB
469 MB
Comparison startup on the tested dataset drops from ~90 s to ~40 s.
…elId
ModelsCategoryCache.load queried the target iModel for the model of every
updated element (800 ids per ECSQL statement) even when the changed
elements data already carried the modelId. Deleted elements already had
this shortcut; updated elements did not.
Apply the same split to updated elements: take the modelId from the change
data when present and only query for elements that lack it.
For comparisons where the Changed Elements API returns modelIds (the
normal case) this removes one round-trip per 800 updated elements, which
on multi-million-element comparisons was ~half of comparison startup time
(tens of seconds, thousands of queries). With modelIds present the cost
is now a single pass over the entries.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ChangedElementEntryCache.getEntries materialized every cached entry via
getAll() and filtered it linearly, and getChangeElementIdsFromModelId did
the same per model. The changes tree provider and the visualization also
scanned the full entry collection each time a single model was expanded or
toggled. On multi-million-element comparisons each of these calls cost
hundreds of milliseconds, and they are issued per row / per model, so
expanding a model node or rendering the inspector list could spend seconds
in scans alone.
- getEntries now resolves ids directly from the entry Map (children too).
- The cache maintains a modelId -> element ids index, updated wherever
entries are written (initialize, _overrideEntriesInCache, cleanup), and
exposes getEntriesWithModel for per-model queries.
- ChangesTreeDataProvider.getModelElementEntries,
getModelAllChildElementEntries and _getChangedModelChildrenById use the
index instead of scanning all entries / all root entries.
- VersionCompareVisualization builds a one-time modelId -> entries map
instead of scanning its entry array on every model visibility check.
Expected savings on large comparisons: per-id lookups drop from ~100-300 ms
to sub-millisecond, per-model id lookups drop from ~250 ms to effectively
free, and expanding a model node in the changes tree roughly halves (the
remainder is the ECSQL load of its children).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The tile Provider rebuilt the secondary iModel FeatureSymbology.Overrides
eagerly in its constructor, in updateOptions, and again from the viewport's
areFeatureOverridesDirty callback that updateOptions itself triggers. A
single inspector filter change (setFocusedElements followed by
toggleUnchangedVisibility) therefore rebuilt the overrides at least twice,
and each rebuild plus every addFeatureOverrides call re-filtered the whole
visible entry array by opcode and allocated fresh id Sets. On
multi-million-element comparisons each rebuild costs several seconds and
over a hundred MB of transient allocations.
- secondaryIModelOverrides is now a getter that rebuilds only on first read
after an invalidation; constructor, updateOptions, setTransparency,
setChangedElems and the viewport dirty callback just invalidate, so
back-to-back changes collapse into one build per frame.
- visibleChangedElems is a setter that partitions entries into
inserted/updated/deleted once; addFeatureOverrides and initOverrides use
the partitions instead of filtering the full array on every call.
- The unfiltered deleted/updated id Sets are cached per partition and reused
when no never-drawn / hidden-deleted filters apply.
Expected savings on large comparisons: roughly 30% off every primary
override pass, one full secondary override rebuild removed per filter
change (about a third of the filter toggle time), and the corresponding
Set churn eliminated. Remaining cost is the per-element override
registration in core-frontend.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
parseJsonResponse always streamed the body through the incremental JSON
parser whenever a body stream was present. That parser exists only to get
past V8's ~512 MiB string limit, but it is several times slower than
native JSON.parse, so every comparison result, including ones far below
the limit, paid the penalty on the critical path of opening a comparison.
When Content-Length is known and under 480 MiB (UTF-8 bytes >= UTF-16 code
units, so the decoded text always fits) the body is now parsed with
response.json(); readChangedElementsPayload already strips the omitted
property keys afterwards for oversized payloads. Larger or unsized bodies
keep using the incremental parser.
Expected savings: payload parsing drops to roughly a third of its previous
time for results below the limit (several seconds on multi-hundred-MB
payloads); results above the limit are unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ChangedElementsManager accumulated the service payload into a
Map<string, ChangedElement>, then ChangedElementEntryCache copied every
element into a ChangedElementEntry. The raw Map was kept alive for the
whole comparison session: the manager held it, the children cache held a
second reference to it for id membership checks, and
getAllChangedPropertyNames iterated it. For multi-million-element
comparisons that is a full duplicate of the change data (hundreds of MB)
retained with no reader other than those two lookups.
- The children cache now receives the entry map (same key set) instead of
the raw Map.
- getAllChangedPropertyNames reads properties from the entry cache.
- ChangedElementsManager.initialize clears the raw Map after
generateEntries; the entry cache is the single source of truth from then
on. Entry objects share the per-element property Maps by reference, so
nothing is lost.
Expected savings: roughly 40% less retained heap after comparison startup
on large results, which also lowers the peak reached during initialLoad and
leaves more headroom for the viewport.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved issues can misclassify unchanged elements, hide original geometry, fail comparisons involving large cross-origin downloads, and break assignments to a previously writable public property.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The change still has a critical unknown-model path that throws instead of returning an empty set, and mutable element replacements can leave opcode partitions stale and produce incorrect override behavior.
Map.get returns undefined for an unknown model, and new Set(undefined) throws a TypeError instead of returning the empty set promised by this method and exercised by the new 0xnone test. Use an empty iterable when the index has no entry.
The reason will be displayed to describe this comment to others. Learn more.
Seems like a lot of solid performance improvements based on knowledge we've built up over time. I'm not seeing anything out of line, except for one comment that I've added.
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
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.
Version compare performance improvements
Five independent fixes to the comparison startup and interaction paths. Measured against a ~10 GB iModel and a 3+ million element comparison result (860 MB full / 265 MB property-less payload).
Changes
ModelsCategoryCache: stop querying the model of every updated element when results already carrymodelId.ChangedElementEntryCache: replace full-cache scans ingetEntries/ per-model lookups with Map lookups and amodelId → idsindex, this enhances the performance of the tree provider and visualization.VersionCompareTiles: build secondary-iModel overrides lazily (once per invalidation instead of twice per filter change) and partition entries by opcode once instead of on every pass.parseJsonResponse: use nativeJSON.parsefor identity-encoded payloads under the 256 MiB property threshold; keep the incremental parser for larger or encoded bodies.ChangedElementsManager: release the raw accumulated change Map after entries are generated; the entry cache is the single source of truth.Benchmark
ModelsCategoryCache.loadgetEntries(1 id)× 20getChangeElementIdsFromModelId× 10Provider.addFeatureOverridesinitializeComparison startup on the tested dataset drops from ~90 s to ~40 s.