Commit e2bdb3d
committed
Update backpressure implementation with runtime configurable threshold
Prior to this commit, the backpressure implementation would
unschedule muted actors immediately after they sent a single
message to a muted/overloaded/under pressure actor. While this
works reasonably well, it does have some rough edges as noted
in #3382 and
#2980.
This commit updates the backpressure implementation that can
have its threshold for when to unschedule an actor sending
to muted/overloaded/under pressure actors be dynamically
controlled via a runtime cli argument. It does this by
separating an actor being muted from when an actor is
unscheduled where an actor is still muted immediately
upon sending a message to a muted/overloaded/under pressure
actor but the threshold controls when an actor is
unscheduled after it has been muted resulting in a more
gradual backpressure system. This threshold based
backpressure should result in less stalls and more overall
forward progress due to allowing muted actors to make some
slow progress prior to being uncheduled.
The updated backpressure logic is as follows (at a high level):
* If sending a message to a muted/overloaded/under pressure actor,
note that the sending actor should mute.
* At the end of the behavior, mark the actor as `muted` if it
is not already `muted` and save the receiver actor info.
* At the end of the behavior, check to see if the actor is over
the threshold.
* If yes, unschedule actor and mark it as `muted and unscheduled`
and finally add the sender and all muters to the scheduler
mutemap (as used to happen previously after 1 message)
* If no, stop processing messages but don't unschedule the actor
* When an actor is no longer overloaded or under pressure, it will
tell the schedulers to unmute all senders that were muted and
unscheduled as a result of sending messages to it
(same as previously)
* When an actor runs it checks if it still needs to stay `muted` or not
and if not, it tells the schedulers to unmute all senders that were
muted and unscheduled as a result of sending messages to it
* The actor also optimistically unmutes itself it successfully
processes a full batch or all messages in its queue and tells the
schedulers to unmute all senders that were muted and unscheduled
as a result of sending messages to it
The updated logic is functionally equivalent to the old backpressure
implentation when the threshold is `1` message.
There is now a new command line argument to control the threshold
for throttling/muting called `--ponymsgstilmute`. This option is
specifically added for power users who want to have more control
over how the runtime handles backpressure. Using a value of `1`
for `--ponymsgstilmute` will result in actors getting muted after
sending a single message to a muted/overloaded/under pressure
actor and be functionally equivalent to the previous backpressure
implementation that did not employ gradual throttling. The
threshold defaults to `10`.1 parent 58134d1 commit e2bdb3d
10 files changed
Lines changed: 302 additions & 53 deletions
File tree
- examples/fan-in
- packages/builtin
- src/libponyrt
- actor
- gc
- options
- sched
- test/libponyc-run/backpressure
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
280 | 281 | | |
281 | 282 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
0 commit comments