-
Notifications
You must be signed in to change notification settings - Fork 42
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
Improve demonitor race precision #281
Merged
aronisstav
merged 17 commits into
parapluu:master
from
aronisstav:improve-demonitor-precision
Aug 20, 2018
Merged
Improve demonitor race precision #281
aronisstav
merged 17 commits into
parapluu:master
from
aronisstav:improve-demonitor-precision
Aug 20, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #281 +/- ##
==========================================
+ Coverage 94.39% 94.48% +0.08%
==========================================
Files 12 12
Lines 3589 3646 +57
==========================================
+ Hits 3388 3445 +57
Misses 201 201
Continue to review full report at Codecov.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This change optimizes the races of demonitor variants, but introduces some weirdness in the reported traces.
Fixes aronisstav#43.
Motivation
Before this PR, Concuerror's handling of races between
demonitor
variants and a monitored process exiting was 'coarse', in the sense that the call todemonitor
would be considered as racing with both theexit
event itself (which would determine if a monitor message will be sent) and the'DOWN'
message being delivered (which determined if the message is placed in the mailbox). This would lead to 3 schedulings being explored: monitor is delivered, monitor is emitted but blocked from delivery while in-flight, or monitor is removed before emission. Currently the decision about whether the monitor will be emitted is taken when the process starts exiting.However, out of four variants of demonitor, only one races with both events (
demonitor(..., [info])
). In contrast, a call todemonitor(..., [flush])
does not race with either the exit or the deliver events: it is irrelevant whether the process exited before or after, as is irrelevant whether the'DOWN'
message has been delivered or not: the message will never exist in the recipient's mailbox.All
gen_
behavior calls use the following pattern from gen.erl:For the
Reply
andafter
cases Concuerror would explore three schedulings instead of just one.Change
In order to treat
demonitor(..., [flush])
as independent from exit and message delivery, we must ensure that all events appear identical in any of the orderings. This leads to the following changes:'DOWN'
messages should be emitted, even if a monitor has been removed before the process exits: Concuerror must be allowed to reschedule independent events in any order it likes, so if demonitor and exit are independent, it must not matter whether they happen in one way or the other. This means thatdemonitor, exit (maybe emit)
should be the same asexit (maybe emit), demonitor
so the monitor must always be emitted. Concuerror will also show a warning when emitting DOWN messages for inactive monitors.'DOWN'
messages for cancelled monitors can no longer be marked asignored
during scheduling: for the same reason, if demonitor and message delivery are independent, they must be identical in the trace. However, theuse_receive_patterns
pass can mark such messages as 'received' and not try to reschedule them.Checklist