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

Use MessagePort for direct connections between modules #254

Open
bemasc opened this issue Apr 8, 2015 · 7 comments
Open

Use MessagePort for direct connections between modules #254

bemasc opened this issue Apr 8, 2015 · 7 comments

Comments

@bemasc
Copy link
Contributor

bemasc commented Apr 8, 2015

Currently, all inter-module messaging passes through the core environment. This effectively requires all message passing to acquire and release a single lock (i.e. the mainloop). This seems likely to create a performance bottleneck when transferring >1000 messages per second, as in uProxy. However, Web Workers are capable of connecting directly using a Transferable MessagePort, which would avoid the need to access the core environment when communicating between modules, and might alleviate this bottleneck.

@willscott
Copy link
Member

firefox explicitly says they don't support this in web workers, so support
would have to be chrome only:
https://developer.mozilla.org/en-US/docs/Web/API/Transferable

On Wed, Apr 8, 2015 at 8:39 AM, Benjamin M. Schwartz <
[email protected]> wrote:

Currently, all inter-module messaging passes through the core environment.
This effectively requires all message passing to acquire and release a
single lock (i.e. the mainloop). This seems likely to create a performance
bottleneck when transferring >1000 messages per second, as in uProxy.
However, Web Workers are capable of connecting directly using a
Transferable MessagePort, which would avoid the need to access the core
environment when communicating between modules, and might alleviate this
bottleneck.


Reply to this email directly or view it on GitHub
#254.

@trevj
Copy link
Contributor

trevj commented Apr 10, 2015

I guess MessagePort is just one possible way of achieving this.

@willscott I seem to remember core.peerconnection had an optimisation for signalling channel message passing; is there any chance that would come in useful here?

@bemasc
Copy link
Contributor Author

bemasc commented Apr 10, 2015

Looks to me like the Firefox way to do this might be SharedWorker.

@iislucas
Copy link
Contributor

Also looks to me like they are planning to support it in the future, which would be cool.

@trevj The important thing freedom channels (that I think you're referring to) give us, at the moment, is that they support avoiding the child-parent freedom message bouncing which otherwise happens when a child module is passing a message to the core environment (without channels they bounce through the parent module - via freedom core env!).

Would be good to have a design doc on channels in freedom so we can review how they work and make sure the they have nice syntax for usage too; I imagine freedom channels could nicely abstract over the mechanism of inter-module communication (MessagePort, or freedom-core env bounced messages).

@bemasc
Copy link
Contributor Author

bemasc commented Apr 10, 2015

The only reference I see to "freedom channels" is #48, which is a bit old and vague. It would definitely be nice to clear up some of these proposals.

@iislucas
Copy link
Contributor

@soycode something fun to think about after firefox testing :)

@trevj
Copy link
Contributor

trevj commented Apr 10, 2015

It would also be a trivial piece of code if we could somehow just insert it in the core context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants