Interrupt long running actors #25

Open
opened 2025-06-03 19:59:58 +00:00 by john · 1 comment
Owner

There is currently no mechanism to interrupt actors that have ran for too long. It's easy to do on the JS side, but if the JS calls a function that dips into C that takes a long time, that actor will be tied up. For now, at least get JS checks in; C in the longer run.

There is currently no mechanism to interrupt actors that have ran for too long. It's easy to do on the JS side, but if the JS calls a function that dips into C that takes a long time, that actor will be tied up. For now, at least get JS checks in; C in the longer run.
Author
Owner

There are two ways we can go about doing this:

  1. If a message takes too long to process, if there are other actors waiting, just cancel the message and push it back to the front of the queue, and run it again later. That timer should be like 1/60 of a second.

  2. More complicated but probably better: if an actor takes too long, pause its stack entirely. Each OS thread made w/ pthread with itself have a coroutine it runs its actors in, done with libco or whatever works. If an actor takes too long, inside the JS interrupt, the thread will start a new coroutine and switch to it; once there are no more fast actors looking for work, that same thread will finally switch back to the coroutine which had the slow actor's turn preserved on it.

There are two ways we can go about doing this: 1) If a message takes too long to process, if there are other actors waiting, just cancel the message and push it back to the front of the queue, and run it again later. That timer should be like 1/60 of a second. 2) More complicated but probably better: if an actor takes too long, pause its stack entirely. Each OS thread made w/ pthread with itself have a coroutine it runs its actors in, done with libco or whatever works. If an actor takes too long, inside the JS interrupt, the thread will start a new coroutine and switch to it; once there are no more fast actors looking for work, that same thread will finally switch back to the coroutine which had the slow actor's turn preserved on it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: john/cell#25
No description provided.