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

RFC: 0-copy support for writing reads #650

Open
vlovich opened this issue Apr 12, 2024 · 2 comments
Open

RFC: 0-copy support for writing reads #650

vlovich opened this issue Apr 12, 2024 · 2 comments

Comments

@vlovich
Copy link
Contributor

vlovich commented Apr 12, 2024

If I'm copying from 1 file to another, currently I have to allocate a DmaBuffer & copy_from_slice the ReadResult into the DmaBuffer. @glommer would it make sense to extend DmaBuffer to have a From<ReadResult> trait and extend it's internal storage enum to hold a ReadResultInner? Or is this a bad idea for some reason?

While I'm at it, does it make sense to extend the write method to be generic over some trait to allow the input for the write to be just a plain old byte slice that only needs to outlive the duration of the write?

@vlovich vlovich changed the title RFC: 0-copy support for writing what was written RFC: 0-copy support for writing reads Apr 12, 2024
@glommer
Copy link
Collaborator

glommer commented Apr 15, 2024

As long as ownership is clear, I don't see anything wrong with that. By the time it materializes on our side, the kernel is done with it already so there's no risk there.

The second one is more complex. I had issues before with the kernel and us not agreeing with what "the duration of the write" is. The standard poll methods are bad for it, because they don't guarantee that the same buffer is used in two invocations if the write doesn't complete. If we go for a specialized API, may work.

@vlovich
Copy link
Contributor Author

vlovich commented Apr 17, 2024

I'm not sure I follow the explanation about the second case. You're saying the completion event comes back but the kernel keeps using the referenced buffer? I'm sure I'm understanding that wrong because that would apply equally to the DmaBuffer case I would imagine which needs to know when to free the underlying buffer.

It sounds like something more nuanced though because you mention a second write and polling but I'm not familiar enough with io_uring to follow. What do you mean by specialized API?

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