Search code examples
multithreadinglanguage-agnosticcpu-usagethread-priority

Will increasing thread priority make my long computation run faster?


Let's say I have a GUI application that performs long computations for the user (for example, video processing). Should I increase the priority of my computation process/thread to make it run faster? What would be the harm in doing so?


Solution

  • Generally no. It's rare that someone would prefer a non-responsive system during a long calculation than a responsive system where the calculation takes a tiny bit longer.

    There are also a variety of reasons that increased priority can result in the calculation actually taking longer. For example, increased pre-emption of other tasks can blow out the CPU caches, making those tasks take longer. This can slow down the task you care about for a variety of reasons, including increased inter-core contention.

    You raise priority when you can't tolerate unpredictable or increased latency.