Faster Parallel.For


Parallelize your code to speed it up several times. It's like C#'s Parallel.For, but simpler and faster.


by Casey Walsh-Warder


Price History +

If your game needs better performance, sometimes parallelism is the answer.


This is a parallel for loop. With a normal for loop, you usually do something with 0, then 1, then 2, and so on, such as changing the value at each index of an array. With a parallel for loop, you can use multiple CPUs to process several at a time. That can make your code run several times faster.


You can already use a parallel for loop in C#. C#'s Parallel.For isn't designed for games though. It has a lot of features, but too much overhead for calling multiple times each frame. It also produces garbage, causing lag spikes.


Faster Parallel.For is (hopefully) faster and doesn't produce garbage.