Extremely high script rate but low script activity (and no loops)

hello, I have a system that calculates positions of npcs relative to the grid below them, it uses a server script that loops through every npc 10 times a second, sends a message to the first actor which then sends a message to the second actor, both actors are fairly simple:

--actor1
local returnevent = script.Parent.Parent.ReturnSignal
local workersrepfolder = game.ReplicatedStorage.Workers
local actor2 = script.Parent.Parent.Actor2

@native function getgridpos(number)
	return math.floor((math.floor(((number - 1) / 5) + 0.5) * 5) + 1) --remember: 1 is offset here
end


script.Parent:BindToMessageParallel('Instruction', @native function(instruction)
	local s1 = getgridpos(instruction[1])
	local s2 = getgridpos(instruction[2])
	task.synchronize()
	local id = game:GetService('HttpService'):GenerateGUID(false)
	actor2:SendMessage('Instruction', {tostring(s1) .. tostring(s2), instruction[3]})
	--print('event fired with id ' .. id)
end)
--actor2
repeat wait() print('waiting') until workspace.TerrainFinishedGenerating.Value == true

local workersrepfolder = game.ReplicatedStorage.Workers
local resultnum

local tabletoinclude = {}
for i, v in ipairs(workspace.CloseUpGrids:GetDescendants()) do
	print(i, v)
	if v.Name == "Grid" then
		table.insert(tabletoinclude, v)
	end
end
local postable = {}
for i, v in ipairs(tabletoinclude) do
	print(i, v)
	postable[tostring(v.Position.X) .. tostring(v.Position.Z)] = v
end

--all of the tables above only run once as the map is done generating and never again

script.Parent:BindToMessageParallel('Instruction', @native function(instruction)
	local curgrid = workersrepfolder:FindFirstChild(instruction[2].ID.Value, true).CurrentGrid
	local val = postable[instruction[1]]
	task.synchronize()
	curgrid.Value = val
end)

all in all, while simulating 1000 npcs, it should logically have a combined rate of no higher than 20000 ((1000 + 1000) * 10), however, the rate ends up being in the hundreds of thousands for BOTH scripts, while the script activity is relatively low

and the script rate increase looks like this, which would normally suggest a recursive loop somewhere

any ideas?

update: I think it has something to do with task.synchronize(), as long as it exists in the scripts, the rate hikes, if it doesn’t then rate stays low

update: no that’s not the case either, i was able to discover something though,

local connection = actor:BindToMessage("Instruction", function(instruction)
	print(received) --as long as this print exists the script rate 
--stays within expected limits
	local s1 = 1
	local s2 = 2
end)

(this screenshot was taken while simulating 200 npcs)

print statements do seem to slow down the script execution as it dumps the to Output, so perhaps not a valid test… Looking at the Rate screenshot, it does look like the actor events are incrementing recursively. How are you initialing the first actor call?

It calls :SendMessage() every for loop iteration, here’s basically the whole script

local actor = script.Actor1


while wait(.1) do
	for i, folder in ipairs(workspace.People:GetChildren()) do
		for j, workermodel in ipairs(folder:GetChildren()) do
			if workermodel:IsA('ObjectValue') then continue end
			local humanoidpos = workermodel.HumanoidRootPart.Position
			actor:SendMessage('Instruction', {humanoidpos.X, humanoidpos.Z, workermodel})
		end
	end
end