mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Add yield intervals for diffing and hydrating processes
- Introduced `DIFF_YIELD_INTERVAL` and `HYDRATE_YIELD_INTERVAL` constants to manage execution pacing during the diffing and hydrating processes, respectively. - Implemented logic to pause execution every specified interval to improve performance and prevent potential blocking in long-running operations. - Enhanced the `diff` and `hydrate` functions to track and yield based on their respective counts, ensuring smoother operation during intensive tasks. These changes aim to enhance the responsiveness of the system during heavy processing tasks by introducing controlled yielding mechanisms.
This commit is contained in:
parent
b85c5f5ec7
commit
354d4c8b21
2 changed files with 18 additions and 0 deletions
|
|
@ -50,6 +50,8 @@ local function shouldDeleteChild(virtualInstance, childInstance)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local DIFF_YIELD_INTERVAL = 1000
|
||||||
|
|
||||||
local function diff(instanceMap, virtualInstances, rootId, serverInfo)
|
local function diff(instanceMap, virtualInstances, rootId, serverInfo)
|
||||||
local patch = {
|
local patch = {
|
||||||
removed = {},
|
removed = {},
|
||||||
|
|
@ -57,6 +59,8 @@ local function diff(instanceMap, virtualInstances, rootId, serverInfo)
|
||||||
updated = {},
|
updated = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local diffCount = 0
|
||||||
|
|
||||||
-- Build a lookup table for visible services (for ignoreHiddenServices check)
|
-- Build a lookup table for visible services (for ignoreHiddenServices check)
|
||||||
local visibleServicesSet: { [string]: boolean } = {}
|
local visibleServicesSet: { [string]: boolean } = {}
|
||||||
if serverInfo and serverInfo.ignoreHiddenServices and serverInfo.visibleServices then
|
if serverInfo and serverInfo.ignoreHiddenServices and serverInfo.visibleServices then
|
||||||
|
|
@ -78,6 +82,10 @@ local function diff(instanceMap, virtualInstances, rootId, serverInfo)
|
||||||
|
|
||||||
-- Internal recursive kernel for diffing an instance with the given ID.
|
-- Internal recursive kernel for diffing an instance with the given ID.
|
||||||
local function diffInternal(id)
|
local function diffInternal(id)
|
||||||
|
diffCount += 1
|
||||||
|
if diffCount % DIFF_YIELD_INTERVAL == 0 then
|
||||||
|
task.wait()
|
||||||
|
end
|
||||||
local virtualInstance = virtualInstances[id]
|
local virtualInstance = virtualInstances[id]
|
||||||
local instance = instanceMap.fromIds[id]
|
local instance = instanceMap.fromIds[id]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,21 @@ local Log = require(Packages.Log)
|
||||||
local invariant = require(script.Parent.Parent.invariant)
|
local invariant = require(script.Parent.Parent.invariant)
|
||||||
local Matching = require(script.Parent.matching)
|
local Matching = require(script.Parent.matching)
|
||||||
|
|
||||||
|
local HYDRATE_YIELD_INTERVAL = 1000
|
||||||
|
|
||||||
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session)
|
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session)
|
||||||
if not session then
|
if not session then
|
||||||
session = Matching.newSession()
|
session = Matching.newSession()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not session.hydrateCount then
|
||||||
|
session.hydrateCount = 0
|
||||||
|
end
|
||||||
|
session.hydrateCount += 1
|
||||||
|
if session.hydrateCount % HYDRATE_YIELD_INTERVAL == 0 then
|
||||||
|
task.wait()
|
||||||
|
end
|
||||||
|
|
||||||
local virtualInstance = virtualInstances[rootId]
|
local virtualInstance = virtualInstances[rootId]
|
||||||
|
|
||||||
if virtualInstance == nil then
|
if virtualInstance == nil then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue