-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Priority Messages #9269
Open
rickard-green
wants to merge
3
commits into
erlang:master
Choose a base branch
from
rickard-green:rickard/prio-msg/OTP-19198
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Priority Messages #9269
rickard-green
wants to merge
3
commits into
erlang:master
from
rickard-green:rickard/prio-msg/OTP-19198
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
The message queue (MQ) can now begin with a priority message queue (PMQ) where priority messages can be appended. The priority message queue is identified using a priority message queue start marker (PMQS) and a priority message queue end marker (PMQE). When a priority message is received it is inserted just before the PMQE marker. MQ -> PMQS -> PrioMsg1 -> ... -> PrioMsgN -> PMQE -> Msg1 -> ... -> MsgN The receive expression will try to match messages from the beginning of the MQ going through the messages in PMQ one by one continuing with non-priority messages when it has reached the end of the PMQ. The selective receive optimization will continue to work. When there are any receive markers present, an incoming priority message will be scanned for receive marker references. If not found, the receive can continue as usual. If a reference found in the priority message corresponds to the currently used receive marker, the priority message will be matched against before continuing with the next ordinary message. If a priority message contains a reference corresponding to a receive marker and the receive marker is used in multiple receive expressions, the second and following receive expressions will have to scan the whole PMQ before continuing to the location of the receive marker. A PMQ receive marker could be inserted preventing this. However, the PMQ is expected to be small, and it is quite unexpected that a reference is part of a priority message, so this has not been implemented.
The action performed when an ordinary message is received, is to append it to the end of the message queue. When receiving a priority marked message that action might not be taken, but instead an alternate action might be taken, i.e, the message might be appended to the end of the priority message queue. There currently exist one type of alternate action messages, namely messages sent using an alias. This commit generalize the alias message passing functionality to alternate action message passing which can be used by priority messages as well as alias messages (and potentially other future alternate action messages). Both local and distributed alternate action messages are supported.
This commit introduce functionality for registering messages that should be accepted as priority messages. Currently these types of messages can be handled as priority messages: * Priority marked messages (sent using the priority option of the send/3 BIF). The receiver registers a pid for which priority marked messages will be accepted. If the priority message is sent from the registered process, it will be accepted as a priority message; otherwise, as an ordinary message. * Exit messages. The receiver registers a pid or port for which exit signals converted to exit messages should be treated as priority messages. Both exit messages resulting from a broken link as well as exit messages resulting from a call to the exit/2 BIF will be accepted as priority messages. Other exit messages will be treated as ordinary messages. * Monitor messages, e.g., 'DOWN' messages. The receiver register a monitor reference for which the corresponding monitor message will be treated as a priority message. Other monitor messages will be treated as ordinary messages. With this commit priority messages will also actually be delivered into the priority message queue implemented in an earlier commit.
garazdawi
requested review from
garazdawi,
kikofernandez,
lucioleKi and
frazze-jobb
January 8, 2025 08:06
I really like the consolidation of the various dist operations for sending a message down to |
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.
Reference implementation for EEP 76 (pull request 73) on the eep repository.