This is kind of a difficult thing to give good advice for, but generally you need to look at how long your Projectile calculations take in relation to the rest of your frame. If it happens right at the end, you’ll know you’re going to need multiple Actor
s to see any benefit, but in other cases, even 1 is enough.
For example, in a case like this, the parallelize-able task happens in the middle of the frame,
, and here, there only needs to be one Actor
to completely remove it’s impact:
I would recommend avoiding having, for instance, 1 Actor
per Projectile, because each Projectile is probably less expensive to compute than the time it takes for the Actor
to receive it’s data to perform it’s calculations on and send it back, because that on it’s own has overhead.
Going back to my previous example, more than 1 Actor
only becomes necessary when Projectiles
goes beyond the blue bar, so the most efficient distribution would be one that has the least amount of Actor
s to prevent that.
Usually what I do, is just have each Actor
perform some number of tasks (in your case each Actor
would be in charge of a certain number of Projectiles), and more Actor
s are used when there are too many tasks per Actor
with the previous number of Actor
s.
For example, if I had 400
Projectiles with 100
Projectiles per Actor
, then:
- 1
Actor
: Too few, this one would have to handle 400
Projectiles
- 2
Actor
s: Same as above, each would have to handle 200
- 3
Actor
s: Same as above, 133
- 134
- 4
Actor
s: Each Actor
only has to handle 100
Obviously, this involves some guesswork, although the best possible distribution could be calculated by measuring the total Actor
time VS the total frame time, taking into account when the Actor
s were kicked-off.