Problem:
If you update 64 beams per frame, it is fast and takes 0.1ms
If you update 65 beams per frame, it takes significantly longer.
The longer you run it for, the slower updating the 65th beam is.
This also applies to trails
Repro:
Generate some beams
Within a frame, update more than 64 of those beams
What my output reads:
--[[
TEST RESULTS:
num beam updates: 64
update time (ms): 0.1
TEST RESULTS:
num beam updates: 65
update time (ms): 23.2
]]
--Put this in a LocalScript in game.StarterPlayer.StarterPlayerScripts
local beams = {}
for i = 1, 100 do
table.insert(beams, Instance.new("Beam", workspace))
end
local frameCount = 0
game:GetService("RunService").Stepped:connect(function()
local updateNumber
if frameCount == 0 then
updateNumber = 64
else
updateNumber = 65
end
frameCount = (frameCount + 1)%2
local t0 = tick()
for i = 1, updateNumber do
--UPDATE THE BEAM IN SOME WAY
beams[i].CurveSize0 = math.random()
end
local t1 = tick()
print(string.format("TEST RESULTS:\n num beam updates: %d\n update time (ms): %2.1f", updateNumber, 1000*(t1 - t0)))
end)
I’ve been having this issue as well. Even when ending a play test in studio, and starting another test, it still has lag. The only way I’ve found to temporarily reduce it again is by restarting studio entirely.
Also I’d like to point out that after the 65th beam, there is no longer an issue. Not sure if this applies to the 129th beam tho.
Hmm I think this is a separate problem from the one I am describing. You should consider making a separate post about your issue. OH AND WELCOME!
I think my post is not clear enough.
If a script makes changes to 65 or more Beam instances in a RunService loop, it has large performance implications. This is not so if the script makes changes to 64 or fewer Beam instances in a RunService loop.
Your post was clear, I accidentally typed “frame” instead of “beam”, my bad. I’m updating the texture speed of about 70 beams and on the 65th I have the same issue you described.
I second this, I got numbers varying from 0.9 to 2.6
It’s not quite 23 ms but it’s definitely an interesting jump up.
edit: ran it for longer and it started to climb up, as OP said. I didn’t notice that at first. Seemed to stabilize around going up to taking 6 ms, going back down, and going back up.