Page MenuHome

Runtime Node Cache: Use clear with reserve
AbandonedPublic

Authored by Iliya Katueshenock (Moder) on Dec 5 2022, 12:38 PM.

Details

Summary

Often, when we clear a vector or map, we expect it to be filled with data of a very similar size.
The overhead of a few extra links isn't that big and only lasts until the next update.
The size that was previously obtained, if it is less than cap, will make the extra selection disappear.
This can be extended to other places as well, but this can be done later.


Test:

MasterPath
Timer 'update node vector': (Average: 1824 ns, Min: 200 ns)Timer 'update node vector': (Average: 1631 ns, Min: 100 ns)
Timer 'update link vector': (Average: 1684 ns, Min: 100 ns)Timer 'update link vector': (Average: 1139 ns, Min: 0 ns)
Timer 'update socket vector': (Average: 11210 ns, Min: 600 ns)Timer 'update socket vector': (Average: 9000 ns, Min: 500 ns)
Timer 'update directly linked links and sockets': (Average: 8069 ns, Min: 500 ns)Timer 'update directly linked links and sockets': (Average: 5649 ns, Min: 300 ns)
Timer 'update toposort': (Average: 21885 ns, Min: 400 ns)Timer 'update toposort': (Average: 26374 ns, Min: 300 ns)
Timer 'update toposort': (Average: 11019 ns, Min: 400 ns)Timer 'update toposort': (Average: 8716 ns, Min: 200 ns)
Timer 'update root frames': (Average: 1639 ns, Min: 100 ns)Timer 'update root frames': (Average: 1955 ns, Min: 100 ns)
Timer 'update direct frames childrens': (Average: 2873 ns, Min: 200 ns)Timer 'update direct frames childrens': (Average: 2666 ns, Min: 100 ns)

Diff Detail

Event Timeline

Iliya Katueshenock (Moder) requested review of this revision.Dec 5 2022, 12:38 PM
Iliya Katueshenock (Moder) created this revision.
source/blender/blenkernel/intern/node_runtime.cc
11

Maybe it was a previously forgotten include.

Hmm, generally clear should already not free the memory so I don't see why this patch should improve things. I'm also not convinced in your timings, the min value suggests that you also measured the time of other node groups that your didn't meant to measure. That can affect the average significantly.

Iliya Katueshenock (Moder) added a comment.EditedDec 7 2022, 9:18 PM

You say it's the timings that have't to change
And I agree
I need to make a more correct benchmark mark. Since I did not time the random actions in the node editor and it is strange that there was an increase results.
Now i need to find out what it was.