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

Provide an API for attachments in shared memory #255

Open
asajeffrey opened this issue Jan 30, 2020 · 5 comments
Open

Provide an API for attachments in shared memory #255

asajeffrey opened this issue Jan 30, 2020 · 5 comments

Comments

@asajeffrey
Copy link
Member

Currently most messages are serialized and deserialized using serde, which means that large messages are copied twice. This is possibly expensive, especially for messages which are being forwarded, ore do not need to be stored on the head (e.g. image data being loaded into a GL texture doesn't need to be first copied into main memory).

Currently there are two special cases: sending channels over channels, and BytesSender. It would be nice if we could generalize this to allow large types to be allocated in shared memory and serialized as an attachment with just the reference to shared memory.

@asajeffrey
Copy link
Member Author

This came up in conversation with @jdm and @pcwalton.

@asajeffrey
Copy link
Member Author

There are traits in https://github.com/asajeffrey/shared-data/ and https://github.com/standard-ai/interprocess-traits for data that can be safely sent and referred to in shared memory, which could be used as the basis of "types that can be added as attachments". cc @lovesegfault @nagisa

@asajeffrey
Copy link
Member Author

Related: #126, #138 and #156

@asajeffrey
Copy link
Member Author

It would also be nice to do this and maintain interop with serde's Serialize and Deserialize traits, since those have quite wide support in third-party crates. In particular if there is a third party Container<T> type with #[derive(Serialize, Deserialize)], it would be nice to be able to use that with attachments. So this probably means we can't intoruduce a trait SerializeWithAttachments: Serialize with support for attachments (and ditto deserialize).

@lovesegfault
Copy link

cc. @Ekleog

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

No branches or pull requests

2 participants