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

WIP: Node WorkerChannel native addon #1394

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

WIP: 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
## Node WorkerChannel addon.
/node/workerChannel/node_modules
/node/workerChannel/build
/node/workerChannel/lib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we include this lib folder in "files" in main package.json? Or should it be managed by the package.json of the addon folder? What I mean is that:

  • We only include JS transpiled files in the mediasoup NPM package and not TS files (AKA node/src folder).
  • Is the addon properly built if we install mediasoup as a git+ssh dependency in the package.json of whatever app using mediasoup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and tested. package.json files are properly edited. adding mediasoup as a git+ssh dependency of a 3rd party app has also been tested.

@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

npm-scripts.mjs Outdated Show resolved Hide resolved
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.

None yet

2 participants