Enhance syncback process by integrating serialization of service children

- Introduced `SerializationService` to serialize child instances during syncback, improving data handling.
- Updated `performSyncback` to include serialized children data in the syncback request.
- Refactored `ServiceChunk` structure to store child count instead of serialized data, optimizing memory usage.
- Adjusted related functions and tests to accommodate the new data structure, ensuring consistency and accuracy in syncback operations.

These changes significantly enhance the efficiency and clarity of the syncback process, allowing for better management of service data.
This commit is contained in:
Joe 2026-02-18 08:21:25 -06:00
parent a823db0297
commit a75a1443c0
7 changed files with 259 additions and 161 deletions

View file

@ -1,5 +1,6 @@
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Players = game:GetService("Players")
local SerializationService = game:GetService("SerializationService")
local ServerStorage = game:GetService("ServerStorage")
local RunService = game:GetService("RunService")
@ -640,18 +641,29 @@ function App:performSyncback()
end
local services = {}
local allChildren = {}
for _, className in SYNCBACK_SERVICES do
local ok, service = pcall(game.FindService, game, className)
if ok and service then
table.insert(services, encodeService(service))
local chunk = encodeService(service)
for _, child in service:GetChildren() do
table.insert(allChildren, child)
end
table.insert(services, chunk)
end
end
local data = buffer.create(0)
if #allChildren > 0 then
data = SerializationService:SerializeInstancesAsync(allChildren)
end
local url = ("http://%s:%s/api/syncback"):format(host, port)
local body = Http.msgpackEncode({
protocolVersion = Config.protocolVersion,
serverVersion = Config.expectedServerVersionString,
placeId = game.PlaceId,
data = data,
services = services,
})

View file

@ -1,5 +1,3 @@
local SerializationService = game:GetService("SerializationService")
local Packages = script.Parent.Parent.Parent.Packages
local Log = require(Packages.Log)
local RbxDom = require(Packages.RbxDom)
@ -24,7 +22,8 @@ return function(service: Instance)
continue
end
local isReadable = propertyMeta.scriptability == "ReadWrite" or propertyMeta.scriptability == "Read"
local isReadable = propertyMeta.scriptability == "ReadWrite"
or propertyMeta.scriptability == "Read"
local doesSerialize = propertyMeta.serialization ~= "DoesNotSerialize"
if isReadable and doesSerialize then
@ -54,20 +53,9 @@ return function(service: Instance)
end
end
local children = service:GetChildren()
local data = buffer.create(0)
if #children > 0 then
local serializeOk, result = pcall(SerializationService.SerializeInstancesAsync, SerializationService, children)
if serializeOk then
data = result
else
Log.warn("Failed to serialize children of {}: {}", service.ClassName, tostring(result))
end
end
local chunk = {
className = service.ClassName,
data = data,
childCount = #service:GetChildren(),
}
if next(properties) then
chunk.properties = properties