Performance benefit from using "matrix Constraints" vs normal Constraints ...

by SplineO posted 53 days ago | 6 comments

So! This might be a dumb question... But is there an actual performance benefit from using the "multMatrix" plus "decomposeMatrix" way of constraining things over using a normal Parent constraint?

I wanted to test this today as I need to rig a ton of nodes to my skeleton .. so I made a version using the matrix and the same setup with parent constraints. I then imported the file several times just so I had around 50 versions of the file in the scene.

I then select the skeleton hierarchy (for all instances) and rotate ALL joints.. Performance overall is the same it both versions, (with around 4 to 5 fps in viewport).

I realize this is by no means a thorough test .. but t still makes me wonder why the performance is roughly the same!

by hazmondo posted 47 days ago

I did a test using the Evaluation Toolkit in Maya 2018, I created 200 driver groups and 200 driven group.

In the first test each driven group was parent and scale constrained to the driver group with an offset and I got the following results: DG: 283.019 fps, Serial: 23.1 fps, Parallel: 70.4 fps

In the second test I used matrix nodes and was careful to use as few as possible, each constraint is created with an offset matrix (multiplyMatrix), a parent space matrix (multiplMatrix) and is then processed (matrixDecomposition) before the translate, rotate and scale attributes were connected and I got the following results: DG: 319.1 fps, Serial: 39.6 fps and Parallel: 100.7 fps

parent constraint

constraint: DG: 277.778 fps, Serial: 29.5276, Parallel: 85.2273

matrix nodes: DG: 288.462 fps, Serial: 42.6136 fps, Parallel: 104.895 fps

scale constraint

constraint: DG: 300 fps, Serial: 38.4615 fps, Parallel: 100.671 fps

matrix nodes: DG: 306.122 fps, Serial: 45.8716 fps, Parallel: 113.636 fps

orient constraint

constraint: DG: 283.019 fps, Serial: 34.4828 fps, Parallel: 95.5414 fps

matrix nodes: DG: 365.854 fps, Serial: 46.1538 fps, Parallel: 110.294 fps

Looks like matrix nodes are the way to go.

by denilson020898 posted 47 days ago

Has decomposMatrix's rotate orders issue been fixed in lastest version of maya?

And also, what about killing the benign cycle of maya constraints? Does that serve more FPS?

by hazmondo posted 46 days ago

I forgot about the rotate order issue with the decomposeMatrix; it still doesn't do anything.


I did six "Test performance" tests, the results for the matrix setup with benign cycles are:

DG = 340.909 fps, Serial = 39.6825 fps, Parallel = 99.3377 fps

DG = 300 fps, Serial = 41.0959 fps, Parallel = 99.3377 fps

DG = 326.087 fps, Serial = 41.3223 fps, Parallel = 102.74 fps

DG = 288.462 fps, Serial = 41.2088 fps, Parallel = 100 fps

DG = 306.122 fps, Serial = 39.6825 fps, Parallel = 102.041 fps

DG = 306.122 fps, Serial = 39.6825 fps, Parallel = 98.0392 fps

DG average = 320.57216666666665, Serial average = 40.445750000000004, Parallel average = 100.24926666666666

the results for the matrix setup without benign cycles are:

DG = 333.333 fps, Serial = 39.1645 fps, Parallel = 100 fps

DG = 333.333 fps, Serial = 39.5778 fps, Parallel = 98.6842 fps

DG = 312.5 fps, Serial = 39.8936 fps, Parallel = 98.0392 fps

DG = 326.087 fps, Serial = 40.9836 fps, Parallel = 98.6842 fps

DG = 365.854 fps, Serial = 38.4615 fps, Parallel = 100 fps

DG = 319.149 fps, Serial = 40.6504 fps, Parallel = 98.6842 fps

DG average = 331.7093333333334, Serial average = 39.78856666666666, Parallel average = 99.01530000000001

It's not exactly conclusive but it seems the benign cycles are a bit faster...

by SplineO posted 44 days ago

Awesome! Thanks for your tests! Looks really promising! I really wish the Rotation Order issue would be fixed, though! :/

by vshotarov posted 50 days ago

Hey! So, for testing stuff like that I usually use the evaluation toolkit in maya 17, as looking at the fps from the HUD is not very reliable as you have to do the averaging yourself.

I usually run each test at least three times and then average the results as you will notice that you get quite different results each time you run the test.

Now for the actual question, I did find a very slight performance benefit when doing a simple benchmark like yours. When I say slight think like 1-2 fps with more than 500 in the scene.

That being said, I think where the setup shines is in more complex networks. If you are watching the Cult of Rig you will probably remember Raff talking about why he tries to avoid maya's native constraints - because they create cycles. Even though they are benign cycles, that creates a cluster in the evaluation that needs to be sorted out before evaluating the rest of the graph. So, in a simple test without many dependencies the difference is expected to be negligible, but once you have a network with a lot of dependencies that performance benefit should start increasing.

I am citing what I've heard Raff and others explain, so don't take my word for it, but it might be something to look into.

chalk shared a really cool explanation about the concept on another thread, so definitely have a look at this. His comment is towards the end.

Hope that helps!

by SplineO posted 50 days ago

Thanks Vasil,

great answer as usual. I'll have a look at the meintioned Post right away. And don't get me wrong. i love the clenness of using the matrix approach. I was just wondering about how bit the improvement might be! I'll have a look at the evaluation toolkit, too. ;)