Skip to content

Commit

Permalink
erts: Fix sigq deferred_save when inner queue is empty
Browse files Browse the repository at this point in the history
If the inner queue is empty, the deferred_save would incorrectly
trigger and set the message queue pointer to the wrong place.
This commit makes it so that the message queue optimization does
not trigger when the inner queue is empty. This is a correct
solution, but not ideal as it means that the message queue optimization
will not help when you have a huge middle queue but en empty
inner queue.
  • Loading branch information
garazdawi committed Nov 4, 2019
1 parent 620ac3e commit b1e7e16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions erts/emulator/beam/erl_message.h
Expand Up @@ -331,6 +331,8 @@ typedef struct erl_trace_message_queue__ {
if ((P)->sig_qs.saved_last) { \
if ((P)->flags & F_DEFERRED_SAVED_LAST) { \
/* Points to middle queue; use end of inner */ \
/* This is later used by erts_proc_sig_handle_incoming */\
/* to set the save to the correct place */ \
(P)->sig_qs.save = (P)->sig_qs.last; \
ASSERT(!PEEK_MESSAGE((P))); \
} \
Expand Down
9 changes: 8 additions & 1 deletion erts/emulator/beam/erl_proc_sig_queue.c
Expand Up @@ -3417,7 +3417,14 @@ stop: {
deferred_saved_last = deferred_save = 0;
}
else {
if (c_p->sig_qs.save == c_p->sig_qs.last)
if (c_p->sig_qs.save == c_p->sig_qs.last &&
c_p->sig_qs.save != &c_p->sig_qs.first)
/* When save is set to last AND DEFERRED_SAVED_LAST is
set we know that we have done a ERTS_RECV_MARK_SET
to the last in order to trigger a clean of the middle
queue. However, we cannot know this when there
are no messages in the inner queue, so in that
case we have to parse the entire queue again */
deferred_save = !0;
else
deferred_save = 0;
Expand Down

0 comments on commit b1e7e16

Please sign in to comment.