otp
otp copied to clipboard
Add option to pause proc timer to erlang:suspend_process/2
We add a pause_proc_timer option to erlang:suspend_process/2. When provided, if the suspendee is waiting on a receive statement, the timer associated to the after clause will be paused, and resumed when the process is eventually resumed.
The main motivation for this is for a debugger to be able to pause all user processes without leading to timeouts.
CT Test Results
3 files 141 suites 50m 59s ⏱️ 1 611 tests 1 562 ✅ 49 💤 0 ❌ 2 329 runs 2 260 ✅ 69 💤 0 ❌
Results for commit 8dda7ef6.
:recycle: This comment has been updated with latest results.
To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.
See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.
Artifacts
// Erlang/OTP Github Action Bot
Thanks for the PR! Most of us are away on vacation so we have limited time to look at this. We'll get back to it once we're back from vacation.
(One thing that strikes me at a glance though is that the commits feel a bit too split up: there's no way to reach the code in the first five commits until the last commit. Feel free to squash, or leave it as-is until we're back :-))
@rickard-green I've pushed a new version that address all previous issues, and indeed is satisfyingly simpler:
- Each call to
suspend_process()with thepause_proc_timeroption requires an eventualresume_process()with theresume_proc_timeroption. - The timer gets resumed whenever the count of pause_proc_timer requests gets to zero, even if the process remains suspended
- For this, we use a counter in the ErtsPausedProcTimer structure and a new counter in the suspend monitor
- We rely again only on rpc signals instead of sys-tasks
Rebased, fixed two errors, and added a "stress-test" that would surface them. The issues where:
- when resuming, the timer needs to be started first, or it will race with receiving a message and clearing the proc timer;
- when suspending, if we fail to send the rpc signal, it's because the process was running and exiting; we mustn't delete the monitor in that case as the suspend signal will still be handled
I finally got to this. Sorry for the long wait! I've rewritten it so that we unconditionally pause the timer on suspend_process() as we talked about. I've pushed a commit which you can amend with your last commit by running git rebase --autosquash -i bcaa4ae648e2d6f20578df1747998247f63be917.
Thanks, @rickard-green ! I rebased the PR, merged your fixup and updated the PR title and description
Something went wrong with the amend of the commit. Changes in erlang.beam and erts_internal.beam are still there. There should not be any changes in those files.
Oops, my bad: I updated them while initially rebasing. Pushed a fixed version