Skip to content

Limit how long an actor may run actions per run #2077

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

Neverlord
Copy link
Member

Instead of adding a limit on how many actions an actor may process in one run, we introduce a new time-based limit. The default for an actor is to stop after 100ms. Users can override this value using the new configuration option caf.scheduler.run-actions-timeout.

Relates #2032.

Copy link

codecov bot commented May 15, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.76%. Comparing base (d41f87b) to head (e6497a5).

Files with missing lines Patch % Lines
libcaf_core/caf/scheduled_actor.cpp 86.36% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2077      +/-   ##
==========================================
+ Coverage   72.72%   72.76%   +0.03%     
==========================================
  Files         635      635              
  Lines       30372    30383      +11     
  Branches     3279     3281       +2     
==========================================
+ Hits        22089    22107      +18     
+ Misses       6387     6371      -16     
- Partials     1896     1905       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

tobim added a commit to tenzir/tenzir that referenced this pull request May 15, 2025
Adds a time based limit for actions on an actor.

actor-framework/actor-framework#2077
@tobim
Copy link
Contributor

tobim commented May 23, 2025

I briefly tested this out with our stack but ran into infinite loops when repeatedly re-enqueuing with a rel_time of 0 from within the action. So these new semantics introduce a case that the client has to guard against that they didn't have to before.

@Neverlord
Copy link
Member Author

@tobim thanks for testing! What function are calling, exactly? delay_for/delay_for_fn? They go though the actor clock and ultimately push the action to the mailbox, so I think I need a bit more context to understand how this change could cause a regression.

Just always re-scheduling a new action from an action will be an infinite chain, so how does your workflow look like? Just from a high level, so that I can come up with a regression test.

@tobim
Copy link
Contributor

tobim commented Jun 5, 2025

@tobim thanks for testing! What function are calling, exactly? delay_for/delay_for_fn? They go though the actor clock and ultimately push the action to the mailbox, so I think I need a bit more context to understand how this change could cause a regression.

We are using delay_until_fn. It some situations it re-enqueues itself with the same abs_time indefinitely.

The code is at https://github.com/tenzir/tenzir/blob/65b7c9eacc1e87f9f1d6c569db29826e2b86dec9/libtenzir/src/execution_node.cpp#L45-L52.

@Neverlord
Copy link
Member Author

@tobim I've made a small tweak, can you re-run your tests with that version and see if it maybe changes something for the better?

Instead of adding a limit on how many actions an actor may process in
one run, we introduce a new time-based limit. The default for an actor
is to stop after 100ms. Users can override this value using the new
configuration option `caf.scheduler.run-actions-timeout`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants