perf(FragmentsModels): memoize localId index lookups in properties controller#245
Merged
Merged
Conversation
…ntroller getItemAttributes and getItemRelations resolved the flatbuffer array index with a linear indexOf scan on every call, making bulk property reads (e.g. getItemsData over all property sets) O(n²). On a 43MB model with 121k property sets this took 18+ minutes; with a memoized localId -> index Map it takes seconds. The flatbuffer accessors return a fresh TypedArray view on every call, so the memo is keyed by the underlying buffer identity and length instead of array identity, and rebuilds automatically if the model buffer changes.
This was referenced Jul 13, 2026
Editing performance: per-item scans of the edit requests list and O(N²) delta rebuild in edit()
#247
Open
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.
Problem
getItemAttributesandgetItemRelationsinVirtualPropertiesControllerresolve the flatbuffer array index with a linearindexOfscan on every call:Any bulk read (e.g.
getItemsDataover all property sets, property panels, relation traversals) becomes O(n²). On a real-world 43 MB model with 121kIFCPROPERTYSETitems, reading pset names + property values viagetItemsDatatook 18+ minutes of CPU.Fix
Memoize a
localId → indexMapfor bothlocalIdsArrayandrelationsItemsArray. The flatbuffer accessors return a fresh TypedArray view on every call, so the memo is keyed by the underlyingbufferidentity + length instead of array identity, and rebuilds automatically if the model buffer changes (e.g. after edits regenerate the buffer). Items created via edit requests are absent from the map, so lookups fall through to the existingindex === -1code path unchanged.Results (real IFC-derived fragments models)
Query results verified identical before/after on real project filters (element sets compared pairwise).
No API changes; single file touched.