Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] Event System and Redundant Callback Executions #1429

Open
jfranmatheu opened this issue Jan 23, 2025 · 0 comments
Open

[Performance] Event System and Redundant Callback Executions #1429

jfranmatheu opened this issue Jan 23, 2025 · 0 comments
Assignees
Labels
bug: performance v3 Applies to RF version 3x

Comments

@jfranmatheu
Copy link
Collaborator

Event System and Redundant Callback Executions

Related issues: #1246

The event subscription system triggers multiple redundant computations due to overlapping callbacks. For example, the Patches tool's update function is subscribed to both 'reset' and 'target_change' events:

@RFTool.on_reset
@RFTool.on_target_change
def update(self):
    # This gets called twice during initialization
    self._recompute()  # Heavy computation

During initialization, both events are triggered separately:

def _reset(self):
    self._callback('reset')        # Triggers update()
    self._update_all()
    
def _update_all(self):
    self._callback('target change')  # Triggers update() again

As another example, some tools may compute in background when navigating the view, making the navigation feel laggy (even when it seems to be mechanisms to try to avoid that).

Implications

  • Redundant computations. Same code runs multiple times in-a-row.

Proposed Solution

Unified Event System:

  • Combine related callbacks to prevent duplicate computations.
  • Implement a smarter event system that can detect and prevent redundant calls.
  • Add event priority/ordering to ensure efficient execution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: performance v3 Applies to RF version 3x
Projects
None yet
Development

No branches or pull requests

1 participant