Process nice/priority on linux

Hi, I just noticed that my Slicer sets itself to a nice value of 19 on linux.
(I noticed this because I let a colleague run some jobs on my desktop.)
What is going on? Is there any way to run it at nice = 0?

Setting background processing priority to low was added 13 years ago, to make GUI more responsive during CLI execution. On Windows, only the processing thread priority is decreased, which is correct behavior. However, on Linux&Mac setpriority function is used, which decreases priority of the entire process.

Could you try if replacing setpriority by pthread_setschedparam works better? Or maybe process prioritization could be removed for Linux&Mac.

What do you experience as a result of running at nice(19)?

Thank you Andras. I was certainly curious about why this decision was made.

What I noticed was launch time. With all cores busy at nice=0, application launch took several minutes.

If I understand your idea, it would be to nice the CLI threads only, and not the UI thread. But I am not sure where this would go. As per your link, I tried changing this in vtkSlicerApplicationLogic::ProcessingThreaderCallback, but it had no effect; the main Slicer thread still runs at nice 19. (Below is my test code.)

  int policy;
  struct sched_param priority;
  int ret;
  ret = pthread_getschedparam (pthread_self(), &policy, &priority);
  priority.sched_priority = 20;
  ret = pthread_setschedparam (pthread_self(), policy, &priority);
  (void)ret; // unused variable

Anyway, might not be worth the effort, because multi-user computers are less common these days.

Does the process priority remain default if you remove priority setting completely? (remove both setpriority calls from vtkSlicerApplicationLogic, I don’t think there is any other place where process priority is changed)

Curiously, it does not. I did a quick grep through the Slicer code, and also the CTK app launcher code, and did not find any other obvious location that setpriority() or nice() is called.

As this is not a high priority for me, we may postpone this investigation. But I’m happy to continue if any other user runs into a problem.

1 Like


I would also like to have the classic medium priority for SlicerAppReal.
I have the expected behaviour if I set priority to 0 in vtkSlicerApplicationLogic::ProcessingThreaderCallback.

It seems there is a solution to decrease the priority of the processing thread on Linux:

Do you think it would be possible to use this code in vtkSlicerApplicationLogic::ProcessingThreaderCallback ?

Best regards

Thank you for investigating this. Could you submit a pull request to with all the changes that fixes the priorities for you?

Does this make a difference on modern multicore systems? I did some quick testing with renice-ing Slicer on macOS (even to -20) and I don’t see much difference in loading speeds for a large volume, for example.