Skip to content
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

worker: prevent event loop starvation through MessagePorts #29315

Closed

Conversation

Copy link
Member

@addaleax addaleax commented Aug 25, 2019

This is a re-do of #28030 that also respects another web platform test (that messages that are queued before a .close() call are also emitted).


Limit the number of messages processed without interruption on a
given MessagePort to prevent event loop starvation, but still
make sure that all messages are emitted that were already in the
queue when emitting began.

This aligns the behaviour better with the web.

Refs: #28030

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@addaleax addaleax added the worker label Aug 25, 2019
@nodejs-github-bot nodejs-github-bot added the c++ label Aug 25, 2019
@addaleax addaleax force-pushed the message-port-event-loop-starvation-2 branch from d69503b to 6db2d79 Compare Aug 25, 2019
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Aug 25, 2019

@addaleax addaleax added author ready and removed author ready labels Aug 25, 2019
@addaleax
Copy link
Member Author

@addaleax addaleax commented Aug 25, 2019

Actually, it looks like this also makes some trouble on Windows.

Trott
Trott previously requested changes Aug 29, 2019
Copy link
Member

@Trott Trott left a comment

Marking with "request changes" so no one accidentally lands this before the Windows tests are passing. Feel free to dismiss this request-for-changes once the tests are passing.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 7, 2019

addaleax added 2 commits Sep 7, 2019
Limit the number of messages processed without interruption on a
given `MessagePort` to prevent event loop starvation, but still
make sure that all messages are emitted that were already in the
queue when emitting began.

This aligns the behaviour better with the web.

Refs: nodejs#28030
@addaleax addaleax force-pushed the message-port-event-loop-starvation-2 branch from 6db2d79 to fab5d00 Compare Sep 7, 2019
@addaleax
Copy link
Member Author

@addaleax addaleax commented Sep 7, 2019

Turns out the timeouts on Windows were happening because the way this change modified behaviour actually impacted performance on Windows noticeably – in CI, that is. I couldn’t reproduce any issues locally.

I’ve rebased this PR and modified it so that at least 1k messages are processed in one batch, which still meets the requirements of not starving the event loop and makes our Windows CI happy.

(I’ll kick off CI but linuxone is down currently so it won’t pass at least because of that.)

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 7, 2019

@Trott
Copy link
Member

@Trott Trott commented Sep 7, 2019

(I’ll kick off CI but linuxone is down currently so it won’t pass at least because of that.)

Not sure who is aware and who isn't, so posting this: According to nodejs/build#1909 (comment), the LinuxONE maintenance outage should be over in less than 5 hours. I imagine if you leave the CI running, it will eventually kick off and (hopefully) pass.

@addaleax addaleax added the author ready label Sep 9, 2019
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 9, 2019

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Sep 9, 2019

@addaleax addaleax dismissed Trott’s stale review Sep 9, 2019

tests pass everywhere

@addaleax
Copy link
Member Author

@addaleax addaleax commented Sep 9, 2019

Landed in b34f05e

@addaleax addaleax closed this Sep 9, 2019
addaleax added a commit that referenced this issue Sep 9, 2019
Limit the number of messages processed without interruption on a
given `MessagePort` to prevent event loop starvation, but still
make sure that all messages are emitted that were already in the
queue when emitting began.

This aligns the behaviour better with the web.

Refs: #28030

PR-URL: #29315
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@addaleax addaleax deleted the message-port-event-loop-starvation-2 branch Sep 9, 2019
targos pushed a commit that referenced this issue Sep 20, 2019
Limit the number of messages processed without interruption on a
given `MessagePort` to prevent event loop starvation, but still
make sure that all messages are emitted that were already in the
queue when emitting began.

This aligns the behaviour better with the web.

Refs: #28030

PR-URL: #29315
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@BridgeAR BridgeAR mentioned this pull request Sep 24, 2019
BridgeAR pushed a commit that referenced this issue Sep 25, 2019
Limit the number of messages processed without interruption on a
given `MessagePort` to prevent event loop starvation, but still
make sure that all messages are emitted that were already in the
queue when emitting began.

This aligns the behaviour better with the web.

Refs: #28030

PR-URL: #29315
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready c++ worker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants