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

Node WorkerChannel native addon #1394

Draft
wants to merge 82 commits into
base: v3
Choose a base branch
from
Draft

Node WorkerChannel native addon #1394

wants to merge 82 commits into from

Conversation

jmillan
Copy link
Member

@jmillan jmillan commented May 9, 2024

Substitute spawning a process with mediasoup for running mediasoup in a thread created by this addon.

The communication is now done via message passing rather than using unixsocket, avoiding the kernel networking stack for each and every message passed from Node to C++ and viceversa.

Performance gains are enhanced by approximately 8 times. Tested by sending a request from Node to C++ and waiting for the response N times in a loop.

Caveats:

  • Since we don't use a separate process, a crash in mediasoup would crash Node, meaning it must be handled by node process signal handling.
    • At the same time, the coredumps will be named something-node-something
    • In order to debug coredumps the worker-channel.node binary can be used along with the coredump file and gdb/lldb

TODO:

  • Document removed 'died' and 'subprocessclose' Worker.ts events.
  • Document removed 'died()' and 'subprocessClosed()' Worker.ts methods.
  • Missing all the prebuilt binary upload/download stuff.

Substitute spawning a process with mediasoup for running mediasoup in a
thread created by this addon.

The communication is now done via message passing rather than using
unixsocket, avoiding the kernel networking stack for each and every
message passed from Node to C++ and viceversa.

Performance gains are enhanced by approximately 8 times. Tested by
sending a request from Node to C++ and waiting for the response N times
in a loop.
.gitignore Outdated Show resolved Hide resolved
@ibc
Copy link
Member

ibc commented May 9, 2024

.prettierignore and .eslintignore should include /node/workerChannel/lib.

node/src/Worker.ts Show resolved Hide resolved
node/src/Worker.ts Show resolved Hide resolved
node/src/Worker.ts Show resolved Hide resolved
npm-scripts.mjs Outdated Show resolved Hide resolved
npm-scripts.mjs Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@ibc
Copy link
Member

ibc commented May 10, 2024

Please merge v3 and check prettier and eslint path arrays in npm-scripts.mjs

Node will clean the native addon once it garbage collects the
corresponding JS instance.
npm-scripts.mjs Outdated Show resolved Hide resolved
@jmillan jmillan changed the title WIP: Node WorkerChannel native addon Node WorkerChannel native addon Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants