we still have multiple issues regarding performance for select all, doing undo and redo, movement improved but can be more
we still have multiple issues regarding performance for select all, doing undo and redo, movement improved but can be more
Originally posted by @l3enQ in https://github.com/Roniasoft/NodeLink/issues/170#issuecomment-1906688449
Not just select all nodes. There is a problem of selecting a large number of nodes.
My initial checks in the past few hours show that the trigger has a lot of CPU usage
https://github.com/Roniasoft/NodeLink/blob/main/resources/View/Helpers/SelectionHelperView.qml#L93
My test method:
- Open simpleNodeLink example
- Load a previously saved file that contains a lot of nodes
- Select all (or almost all) the nodes by mouse drag
- Close the app
I'd profile the app using this simple senario (for just focusing on the selection) and in the result:
- The timer that I linked was only executed twice, but it took a large part of the CPU consumption.
- The trigger method of this timer takes 64% of the CPU clock, 61% of which is in line 103.
- As a result, This method is executed for all nodes and the selectedModelChanged signal is emitted for each one.
I am trying to find a way to emit this signal once and optimize the code
Update 1:
I changed the code so that the selectedModelChanged signal is emitted only once, but the problem was not solved (Of course, this change should be applied in any case).
This method still consumes a lot event in case of emitting the signal once.
This is the execution time of this method, as the number of selected nodes increases, the execution time also increases (in this process, the mouse button is not released).
qml: Elapsed time 114 ms in 8 item(s)
qml: Elapsed time 902 ms in 75 item(s)
qml: Elapsed time 1269 ms in 109 item(s)
Apparently, the problem is due to the bindings given to property SelectionModel.selectedModel. In places like checking if node is selected or not.
Currently, I am trying to understand where this binding takes the most time.
Update 2: There are a lot of reference to selectedModel in the project. I must check all of them and find a more optimal way .
Update 3:
When selecting nodes, these bindings consume more resources than others
https://github.com/Roniasoft/NodeLink/blob/main/resources/View/InteractiveNodeView.qml#L14 https://github.com/Roniasoft/NodeLink/blob/main/resources/View/InteractiveNodeView.qml#L35 https://github.com/Roniasoft/NodeLink/blob/main/resources/View/InteractiveNodeView.qml#L565 https://github.com/Roniasoft/NodeLink/blob/main/resources/View/InteractiveNodeView.qml#L576 https://github.com/Roniasoft/NodeLink/blob/main/resources/View/InteractiveNodeView.qml#L579 https://github.com/Roniasoft/NodeLink/blob/main/resources/View/PortView.qml#L31 https://github.com/Roniasoft/NodeLink/blob/main/resources/View/PortView.qml#L53