How do I optimize VisualScriptingCanvas?

When the user changes any value on a Unit, it gets undefined and then defined again. This causes its connections to be removed, which causes VisualScriptingCanvas.Recollect to be called, which causes CacheWidgetCollections, CacheWidgetItems, and CacheWidgetPositions to be called, all of which are very slow for large graphs. This is problematic when typing values or moving sliders: the editor gets so slow it misses inputs.

I’m looking to optimize VisualScriptingCanvas somehow, but it’s hard to find meaningful wins given the event driven nature of the framework. Has anyone done any work in this area? Any advice?

Idea 1: Don’t make units redefine on trivial changes?
Idea 2: Somehow put the existing connections aside, let the Define run, and then skip undefining and restoring the unit if nothing changed? So that GraphElementCollection.CollectionChanged never fires on trivial changes.
Idea 3: Change Recollect to only refresh the unit and its connections?
Idea 4: Make controls not update the values immediately, like DelayedTextField, but for everything?

Got a 4x speedup when making changes to nodes that do not cause the ports to change. What I did is, I changed Unit’s ControlInput, Relation, etc. functions that are used in Definition to add ports to put them into temporary lists, and changed Define to run Definition first, then check if the new ports are the same as the old ports. If they are, skip everything, else call Undefine and then add the new ports to the unit’s port lists. This way, graph.elements.CollectionChanged is not called for most changes, skipping the expensive refresh of everything. UnitEditor needs a call right after unit.Define to every port’s Describe to make sure the port UI still updates when the ports were not replaced.