Page MenuHome

Merge per-shader SVM nodes in the main update thread to avoid locking and resizing overhead

Authored by Lukas Stockner (lukasstockner97) on Wed, Jul 31, 8:35 AM.



In a test file containing 1300 copies of the same shader, this reduces shader update time from 3.1 sec to 0.05 sec.

Also, this saves one int4 per shader that was overallocated previously, but I doubt that that will ever matter :)

Thanks to @Stefan Werner (swerner) for noticing this issue.

Diff Detail

rB Blender

Event Timeline

Note that the merging step could also be done multithreaded by using atomic fetch_and_add to count the total nodes while getting the own per-thread offset, then allocating the memory in the main thread and then copying the nodes to the position from before in each thread. However, this would require some way of synchronizing the threads and I doubt that the additional complexity is worth it.

This is indeed better approach for threading performance.
Is there a noticeable memory peak with this change?



This revision is now accepted and ready to land.Wed, Jul 31, 12:03 PM

Memory spike shouldn't be too bad, even with the 1400 copies of the fairly complex shader it's only 10MB (and that's before the mesh and image sync).


Good point, I'll change that.