A2UI icon indicating copy to clipboard operation
A2UI copied to clipboard

[javascript] Optimize DataModel Notification Strategy

Open jacobsimionato opened this issue 8 months ago • 9 comments

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

  1. Trie Structure: Replace the flat Map<string, Signal> for signals with a Trie (Prefix Tree).
  2. Efficient Lookup: When a path like /user is updated:
    • Bubble: Traverse up the tree to notify ancestors.
    • Cascade: Visit the subtree at user to notify all descendants.
  3. 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

jacobsimionato avatar Mar 13 '26 02:03 jacobsimionato

Can I take this issue? trie optimization looks interesting.

Mindev27 avatar Mar 14 '26 02:03 Mindev27

Adding the triage: flag label: the latest reply is from an external contributor and has gone unanswered for more than 1 day.

github-actions[bot] avatar Jun 30 '26 16:06 github-actions[bot]

Adding the triage: flag label: the latest reply is from an external contributor and has gone unanswered for more than 1 day.

github-actions[bot] avatar Jun 30 '26 16:06 github-actions[bot]

Adding the triage: flag label: the latest reply is from an external contributor and has gone unanswered for more than 1 day.

github-actions[bot] avatar Jun 30 '26 16:06 github-actions[bot]

A2UI Triage: Marking as P3 because this is an optimization.

jacobsimionato avatar Jul 01 '26 02:07 jacobsimionato

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 avatar Jul 01 '26 02:07 Mindev27

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?

polina-c avatar Jul 27 '26 00:07 polina-c

@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.

nan-yu avatar Jul 30 '26 17:07 nan-yu

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.

nan-yu avatar Aug 03 '26 22:08 nan-yu