Repository navigation
🐛 Skip Model Serialization when Reloading All Nodes - #437
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For so long, Xircuits Canvas was serializing the entire model on every
onChangeevent (e.g., delete node, create node, reconnect ports). For massive workflows (+100 components), pressing Reload All resulted in repeated calls of:which caused hundreds of MBs (even GBs) of
(string)and(concatenated string)allocations in memory, leading to significant slowdowns.The Challenge
Xircuits has 3 different "canvas memory" systems:
Previously, every action would serialize the React diagram → update JupyterLab doc model → deserialize back. This constant serialization/deserialization cycle was necessary to maintain proper xircuits react diagram types (eg ensuring "triangle-link" instead of "default" links) and keep all three memory systems in sync.
The (Temp) Solution
This PR implements a conditional serialization mechanism for reload all:
skipSerializationRef.current = true, then manually mark the context as dirty afterwardWe see that
(concatenated string)dominance during reloadsPull Request Type
Type of Change
Tests
Memory and Performance Test
Steps to Record and Check Memory:
(concatenated string)entries in heap snapshots.(string).You can use this canvas:
https://gist.github.com/MFA-X-AI/3c5b1174885ee322eea57be625076b14
It contains 64 Print components + 64 Literal Strings.
Functional Behaviour Tests
Ensure core behaviours remain unchanged:
Node updates
Link updates
Link point updates
Port updates
Save operations
Environment Tested On:
Note
This PR is a patch that addresses the immediate memory issues during Reload All operations. The proper long-term solution would require reworking how the 3 memory systems (disk file, JupyterLab doc model, and React Diagram engine) synchronize with each other, potentially eliminating the need for constant serialization/deserialization cycles while maintaining data integrity and xircuits react diagram type consistency.