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

transferables in gloo-worker #240

Open
jneem opened this issue Aug 2, 2022 · 3 comments
Open

transferables in gloo-worker #240

jneem opened this issue Aug 2, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@jneem
Copy link

jneem commented Aug 2, 2022

gloo-worker uses post_message to send serialized messages between workers. For some messages, it might be better to use post_message_with_transfer to send partially serialized messages while avoiding expensive copies. For example, if I had a struct like

struct Foo {
  bar: i32,
  baz: f64,
  giant_array: web_sys::ArrayBuffer,
}

then I'd like to send this between workers by serializing the first two fields and transferring giant_array. Is this a use-case that gloo-worker is interested in supporting? The implementation I have in mind would involve custom Serialize-Deserialize-like traits and a derive macro...

(edit: I didn't mean to add the "bug" label, sorry, but it looks like I can't remove it)

@jneem jneem added the bug Something isn't working label Aug 2, 2022
@BuggStream
Copy link

Has any work been done to address this limitation? Or is there a workaround available somewhere else? This is something I really need right now.

@jneem
Copy link
Author

jneem commented Mar 20, 2023

I've been just doing my workers "by hand" instead of using gloo-worker. I'm "serializing" my structs to javascript Arrays by hand and using post_message_with_transfer. It's a bit painful, but it's doable if you only have a couple different kinds of structs to send.

@isosphere
Copy link

I'm working on doing this "by hand" myself, and I found this trunk example to be instrumental in doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants