Are there any performance issues with task.synchronize() and desynchronise if I try to use multiple in one thread?
E.g.
-- work
local a = 0
task.desynchronize()
for i = 1, 1000000 do
a += 1
end
-- what happens when the work above finishes before the next frame?
-- does the work below wait until the next frame?
task.synchronize()
for i = 1, 100 do
a += 1
end
task.desynchronize()
for i = 1, 1000000 do
a += 1
end
For context, I’m doing some parallel lag compensation. I need to do desynchronize when getting all the frame data, but needing to synchronize again to move all the hitboxes to that position, then desynchronize again to do the actual raycasting checks. Then FINALLY synchronizing to send the remote events.
From the docs we know that these are yielding functions and that they suspend execution until there’s an opportunity to switch to serial/parallel context.
If I remember correctly there really was only one point per frame for running parallel, but multiple were added by the time of the full release.
Update
More about scheduling in the latest release and comments.