2013-05-08

Get the Balance Right: mental ray thread priority in 3ds max 2014

Hello World!

As promised (but later than I promised), some news about the new 3ds Max 2014 release that may not be immediately obvious.

 One thing we changed in 3ds max 2014 was the thread priority of the mental ray render threads - they now default to "Below Normal", and when rendering in the background (i.e. via Backburner), one notch lower than that.

 Most people praise this, and say things like "Woohoo, I can finally read my email while rendering" or "When we use the sales departmens machines as render slaves, they don't even know we are doing it any more, mouhahaha, hahaha, ha ha ha haaaaaaaaaaaaaa"

However, once or twice someone says things like "Hey, my 3d screen saver on my render slave took all the CPU and now my render is still at 1% a week later, you suck!!"

So the question is - can this behaviour be changed?

YES IT CAN.

In your 3ds max directorys subdirectory "plugcfg_ln" you will find a file called "mentalray_cpu.ini", which is fairly self-explanatory, but reads something akin to this:
;
; - mentalray_cpu.ini
;
; Sets thread priority and thread count for mental ray renderer.
; Meaning of Thread Priority numbers are
;    0 == Normal
;   -1 == Below Normal
;   -2 == Lowest
; Meaning of Thread Count numbers are
;    0 == Use as many threads as there are cores
;    N == Use N threads
;   -N == Use as many threads as there are cores, minus N
;
[Threads]
;
; Settings for normal / interactive renders in the UI
;
;   Thread priority (defaults to -1 = "Below Normal")
RenderThreadPriority=-1
;   Thread count  (defaults to 0 = use all cores)
RenderThreadCount=0
;
; Settings for backburner / network renders
;
;   Thread priority (defaults to -2 = "Lowest")
BgRenderThreadPriority=-2
;   Thread count  (defaults to 0 = use all cores)
BgRenderThreadCount=0
As you can see, we can set both thread count and thread priority by fiddling with this file. [Note: this file is read at Startup, so any changing of it needs you to restart your Max!]

For thread priority we use the same parametrs as Windows does, where 0 is "same/Normal", -1 is "Below normal" and -2 is "Low". I advice you not to try a positive value, or you may not actually be able to move your mouse until the render completes....

For thread count, I made it such that if the value is zero, it does what it always did in the past - use all the cores.

However, if the value is positive, it will launch that number of threads - completely ignorind the number of cores on your machine. You can set it to 4 on an 8-core or 8 on a 4-core, doesn't matter, it's up to you - there may in some cases even be a benifit in using more threads than actual cores, but your mileage may vary.

Finally, if you set a negative value, it will take that many threads less than the available number of cores. This is really intended for the use case of using the accounting departments machines stealthily as render slaves.... leave them some CPU to do their spreadsheets on!


I hope this helps keeping your priorities straight!


/Z


6 comments:

city said...

thanks for share..

Rawalanche said...

I know i should not post it here, as it's an offtopic, but since it is a recent post, there is at least some chance you will read it ;)

Is there any chance you could release an updated SkinPlus material that actually works with render elements. So we can at very least make some masks for skin materials via labeled element map?

Kentzin said...

Hello! thanks for sharing this information!

Is there a way to do this in 3ds max 2013? I would apriciate it a lot!! thanks!

Richard Glithro said...

if anyone is having trouble with edits to the mentalray_cpu.ini file not doing anything check the following loction:

C:\Users\USERNAME\AppData\Local\Autodesk\3dsMax\20 14 - 64bit\ENU\plugcfg_In\

editing this version of file rather than the one in C:\Program Files\Autodesk\3ds Max 2014\plugcfg_ln\ results in the expected behaviour.

Kate said...

I tried this and it made no difference. I tried it in both the originally posted location and the one Richard mentioned above. I'm running a test file to try to get 2014 as fast as 2013. It's just 1 teapot, a plane, and a daylight system. So far, the best I can get in 2014 is 15 seconds. In 2013, it renders in 4 seconds, default settings. Will keep trying.

Joel Howe said...

I thought that this wasn't working as well, but upon further review, changing the settings in the C:\Users\... location did the trick. I set my thread counts to -1, but rather than simply shutting down an entire core as I usually would by changing the affinity settings in Task Manager, it appears that each thread is being utilized evenly. On my machine with a hex-core processor (12 threads), setting a RenderThreadCount of -1 doesn't shut one thread or logical CPU out of the render process. Instead it looks like each thread is running at very close to (11/12ths?) full capacity.