Add matching session caching and native codegen improvements

- Introduced a new matching session caching mechanism in the Lua matching module to enhance performance with native code generation.
- Rewrote the Lua matching algorithm to utilize session-based caching, reducing redundant computations and improving efficiency.
- Updated Rust implementations to include session caching, ensuring consistency across both Lua and Rust.
- Enhanced the `hydrate` function to support session management during instance hydration.
- Added comprehensive tests to validate the new caching mechanism and its integration with existing functionality.

These changes significantly improve the performance and maintainability of the matching process in the application.
This commit is contained in:
Joe 2026-02-18 04:55:31 -06:00
parent 307ac81aec
commit b39c01e5e9
14 changed files with 1674 additions and 461 deletions

View file

@ -13,7 +13,7 @@ local Log = require(Packages.Log)
local invariant = require(script.Parent.Parent.invariant)
local Matching = require(script.Parent.matching)
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance)
local function hydrate(instanceMap, virtualInstances, rootId, rootInstance, session)
local virtualInstance = virtualInstances[rootId]
if virtualInstance == nil then
@ -40,12 +40,14 @@ local function hydrate(instanceMap, virtualInstances, rootId, rootInstance)
end
end
-- Use the 3-pass matching algorithm to pair virtual ↔ studio children
local result = Matching.matchChildren(validVirtualIds, existingChildren, virtualInstances)
local result = Matching.matchChildren(
session, validVirtualIds, existingChildren, virtualInstances,
rootId, rootInstance
)
-- Recursively hydrate matched pairs
for _, pair in result.matched do
hydrate(instanceMap, virtualInstances, pair.virtualId, pair.studioInstance)
hydrate(instanceMap, virtualInstances, pair.virtualId, pair.studioInstance, session)
end
-- Log unmatched virtual children (no Studio counterpart found)