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

@ -538,6 +538,32 @@ pub fn make_rbxl_from_chunks(chunks: &[librojo::web_api::ServiceChunk]) -> Vec<u
}
}
let visible_services = [
"Lighting",
"MaterialService",
"ReplicatedFirst",
"ReplicatedStorage",
"ServerScriptService",
"ServerStorage",
"SoundService",
"StarterGui",
"StarterPack",
"StarterPlayer",
"Teams",
"TextChatService",
"VoiceChatService",
"Workspace",
];
let existing: std::collections::HashSet<String> = chunks
.iter()
.map(|c| c.class_name.clone())
.collect();
for &svc in &visible_services {
if !existing.contains(svc) {
dom.insert(root_ref, rbx_dom_weak::InstanceBuilder::new(svc));
}
}
let service_refs: Vec<Ref> = dom.root().children().to_vec();
let mut buf = Vec::new();
rbx_binary::to_writer(&mut buf, &dom, &service_refs).unwrap();

View file

@ -200,6 +200,7 @@ fn syncback_matching_ufowave_textures() {
eprintln!("Expected face distribution: {:?}", expected_faces);
// Run syncback matching
let session = librojo::syncback::matching::MatchingSession::new();
let result = librojo::syncback::matching::match_children(
&input_textures,
&expected_textures,
@ -207,6 +208,7 @@ fn syncback_matching_ufowave_textures() {
&expected_dom,
None,
None,
&session,
);
assert_eq!(
@ -306,7 +308,8 @@ fn forward_matching_ufowave_textures() {
assert!(!snap_textures.is_empty(), "No Texture children found");
// Run forward sync matching
let result = librojo::snapshot::matching::match_forward(snap_textures, &tree_textures, &tree);
let session = librojo::snapshot::matching::MatchingSession::new();
let result = librojo::snapshot::matching::match_forward(snap_textures, &tree_textures, &tree, &session);
assert_eq!(
result.matched.len(),