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

Transferable Objects for Dart's Isolates #4149

Closed
DartBot opened this issue Jul 19, 2012 · 16 comments
Closed

Transferable Objects for Dart's Isolates #4149

DartBot opened this issue Jul 19, 2012 · 16 comments
Labels
closed-obsolete Closed as the reported issue is no longer relevant library-isolate web-libraries Issues impacting dart:html, etc., libraries

Comments

@DartBot
Copy link

DartBot commented Jul 19, 2012

This issue was originally filed by JayYoun...@gmail.com


During Eric Bidelman's "The Web Can Do That?!" talk at I/O, he demonstrated using a new version of window.postMessage that transfers ownership of the message object instead of copying it. This avoids the overhead of copying altogether. It looks like this is already in the HTML5 spec[1] and is implemented behind a vendor prefix in Webkit[2]. From the looks of it, we're going to have this in JS eventually. This seems like a great fit for Dart's isolates as well. I love the idea of actor-based concurrency, but I've always been turned off by the cost of message cloning.

Thanks!

[1] http://dev.w3.org/html5/spec/common-dom-interfaces.html#transferable-objects
[2] http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast

@dgrove
Copy link
Contributor

dgrove commented Jul 19, 2012

cc @lexprfuncall.
Set owner to @rakudrama.
Added Area-DOM, Triaged labels.

@iposva-google
Copy link
Contributor

Removed Area-DOM label.
Added Area-HTML label.

@vsmenon
Copy link
Member

vsmenon commented Aug 15, 2012

I don't expect we'll get to this before M1, so marking as later.

In JS, background isolates are just workers, so we should be able to leverage window.postMessage (on browsers where transferable is supported). In Dartium, we'd need another way to do this I think. Thoughts?


cc @rakudrama.
Removed the owner.

@vsmenon
Copy link
Member

vsmenon commented Aug 15, 2012

Added this to the Later milestone.

@DartBot
Copy link
Author

DartBot commented Aug 16, 2012

This comment was originally written by schwa...@gmail.com


It actually looks pretty straightforward, at least from Dart-to-Dart. Only a handful of object-types will support the Transferable interface. Let's consider ArrayBuffer... how is this implemented in V8? I assume there is a special JS object that lives on the V8 heap that contains a non-accessible pointer to the ArrayBuffer payload on the C heap. Transferring to/from another worker consists of:

  • creating a new ArrayBuffer JS object that will be accessible in the destination
  • filling in the pointer to point at the same payload as the original ArrayBuffer
  • "neutering" the original ArrayBuffer by setting its C-heap pointer to NULL

I doubt that the existing V8 implementation could be shared, but I imagine the port to Dart would largely be transcription to Dart's embedding-API.

In this scheme, it would also be possible to transfer Transferable objects between V8 and Dart, in much the same way. Some details would need to be handled, like ensuring that the source and destination objects are pinned during the transfer operation (i.e. no GCs); I'm not sure whether the embedding APIs support this easily.

The more difficult case is what to do about sending regular objects between V8 and Dart, since their object-models are so different. Perhaps a JS object could be transformed into a Dart Map whose values are other Maps (corresponding to regular JS objects), or other types corresponding to the JS types (such as String or double). In the other direction, only a such a Dart map could be sent... if it contains instances of class other than the allowed few, an exception would be thrown. But I digress...

@DartBot
Copy link
Author

DartBot commented Aug 16, 2012

This comment was originally written by sc...@gmail.com


Just wanted to emphasize that I didn't intend to trivialize this... I remember looking at the changes required to enable multi-VM support in WebKit, and understand that this is all much harder in reality than it is conceptually.

@justinfagnani
Copy link
Contributor

Added Library-Isolates label.

@dgrove
Copy link
Contributor

dgrove commented Jan 11, 2013

Added Library-Isolate label.

@dgrove
Copy link
Contributor

dgrove commented Jan 11, 2013

Removed Library-Isolates label.

@efortuna
Copy link
Contributor

Transferables should be working now.


Added AssumedStale label.

@DartBot
Copy link
Author

DartBot commented Sep 6, 2013

This comment was originally written by @pjako


Have not seen any changes to this in the commits to the VM, transferables don't work, at least when dart runs on the DartVM.

@DartBot
Copy link
Author

DartBot commented Nov 9, 2014

This comment was originally written by @pjako


One year later... is this feature still on the table?

@DartBot
Copy link
Author

DartBot commented Nov 9, 2014

This comment was originally written by @mezoni


One year later... is this feature still on the table?

One year is not a three years.
Please, wait again...
...one year.

@DartBot DartBot added Type-Defect web-libraries Issues impacting dart:html, etc., libraries library-isolate closed-obsolete Closed as the reported issue is no longer relevant labels Nov 9, 2014
@DartBot DartBot added this to the Later milestone Nov 9, 2014
@nawafnaim
Copy link

Are transferable objects supported by Dart now? Chrome 17+ and Firefox 18+ supports them based on https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers

@alan-knight
Copy link
Contributor

I believe it works when compiled to JS. I suspect it doesn't work between Dart isolates, as that would have nothing to do with the browser implementation. But for performance optimization, presumably what's more important is the production version.

@lexaknyazev
Copy link
Contributor

Not sure about DartVM, but as of 1.20, dart2js version of SendPort.send() doesn't support transferable objects.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant library-isolate web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

9 participants