[javascript] Optimize DataModel Notification Strategy
Proposal: Optimize DataModel Notification Strategy
Reason
The current DataModel.notifySignals implementation performs a linear scan of all registered signals to find descendants whenever a value is updated. This becomes a performance bottleneck as the number of reactive bindings grows.
Design
- Trie Structure: Replace the flat
Map<string, Signal>for signals with a Trie (Prefix Tree). - Efficient Lookup: When a path like
/useris updated:- Bubble: Traverse up the tree to notify ancestors.
- Cascade: Visit the subtree at
userto notify all descendants.
- Complexity: This reduces notification overhead from $O(N)$ (where $N$ is total signals) to $O(P + D)$ (where $P$ is path depth and $D$ is the number of actual descendants).
Key Files
renderers/web_core/src/v0_9/state/data-model.ts
Can I take this issue? trie optimization looks interesting.
Adding the triage: flag label: the latest reply is from an external contributor and has gone unanswered for more than 1 day.
Adding the triage: flag label: the latest reply is from an external contributor and has gone unanswered for more than 1 day.
Adding the triage: flag label: the latest reply is from an external contributor and has gone unanswered for more than 1 day.
A2UI Triage: Marking as P3 because this is an optimization.
Hi! I previously asked about taking this issue, but I think my comment got buried. Since the issue is still open and unassigned, I’d be happy to work on the Trie-based optimization if it’s still available.
Mindev27, thank you for offering your help.
We are doing some redesigning and I am afraid your work may become tossed.
@jacobsimionato , @ditman , do you have better understanding of the plans for web code?
@jacobsimionato I think this is still needed and orthogonal to the Node Layer API that @andrewkolos is working on.
If it looks good to you, I'll remove the status: in-discussion label.
This is prioritized as a P3. I'll go ahead with removing the status: in-discussion label. When we actually assign this enhancement to an owner, we can have more discussions.