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
Comments
cc @lexprfuncall. |
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. |
Added this to the Later milestone. |
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:
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... |
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. |
Added Library-Isolates label. |
Added Library-Isolate label. |
Removed Library-Isolates label. |
Transferables should be working now. Added AssumedStale label. |
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. |
This comment was originally written by @pjako One year later... is this feature still on the table? |
This comment was originally written by @mezoni
One year is not a three years. |
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 |
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. |
Not sure about DartVM, but as of 1.20, dart2js version of |
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
The text was updated successfully, but these errors were encountered: