Dynamo
Dynamo copied to clipboard
WorkspaceViewModel fast node and connector lookup
Purpose
When changing many nodes and connectors at the same time during deletion, undo and redo, a lot of time is spent looking for the end nodes of connectors. The current implementation of the WorkspaceViewModel uses an ObservableCollection to hold the nodes, which essentially is the same as a list. Since the connector ends are being looked up using linq, this has much worse performance than looking up nodes in a dictionary.
This PR adds a dictionary that lives alongside the ObservableCollection. This increases memory usage somewhat, but means lookups can be much faster.
Deleting and undoing a large amount of nodes on the MaRS model takes delete from about 10 to 5 seconds, and undo from about 40 to aobut 5 seconds.
Doing the same on the Car_Configurator takes the delete time from about 2m20s to about 12 seconds, and undo from about 2m35s to 30s.
It also shaves off a little bit of time when opening a workspace from json.
Performance
Deletion (old)
Deletion (new)
Undo deletion (old)
Undo deletion (new)
Open json from path (old)
Open json from path (new)
Declarations
Check these if you believe they are true
- [ ] The codebase is in a better state after this PR
- [ ] Is documented according to the standards
- [ ] The level of testing this PR includes is appropriate
- [ ] User facing strings, if any, are extracted into
*.resxfiles - [ ] All tests pass using the self-service CI.
- [ ] Snapshot of UI changes, if any.
- [ ] Changes to the API follow Semantic Versioning and are documented in the API Changes document.
- [ ] This PR modifies some build requirements and the readme is updated
- [ ] This PR contains no files larger than 50 MB
Release Notes
N/A
Reviewers
@mjkkirschner
FYIs
@dimven