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

Can we use fixed buffers for UringSocket? #55

Open
armanbilge opened this issue Mar 30, 2023 · 4 comments
Open

Can we use fixed buffers for UringSocket? #55

armanbilge opened this issue Mar 30, 2023 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@armanbilge
Copy link
Owner

https://unixism.net/loti/tutorial/fixed_buffers.html

  • I've seen examples for file I/O, but its unclear if they are possible / useful for network I/O
  • buffers have to be registered ahead-of-time, which seems tricky to architect
@armanbilge armanbilge added enhancement New feature or request question Further information is requested labels Mar 30, 2023
@mox692
Copy link
Contributor

mox692 commented Apr 18, 2023

I created a simple C program and experimented it, and it seems possible to read and write sockets using fixed_buffer apis such as io_uring_prep_write_fixed and io_uring_prep_read_fixed.

If my understanding is correct, fixed buffers are associated with io_uring, which is used throughout the program, so if we want to use fixed buffers we will need to add some buffer management logic somewhere, but I don't think it's difficult to do.

@armanbilge
Copy link
Owner Author

@mox692 nice job, that's great! Are there _fixed versions for send and recv too, which is what we are currently using for sockets?

If my understanding is correct, fixed buffers are associated with io_uring, which is used throughout the program, so if we want to use fixed buffers we will need to add some buffer management logic somewhere, but I don't think it's difficult to do.

Yes, I believe that's right. But I think we need to decide how many buffers we want and how big they should be so that we can pre-allocate them. Maybe that's okay, but I felt a bit unsure about it, particularly for services that expects to have lots of connections.

@mox692
Copy link
Contributor

mox692 commented Apr 19, 2023

Are there _fixed versions for send and recv too

Ah, I missed that point. The program I used for the experiment was using the _fixed version of read/write, not recv/send. (my very rough example here )

But, now I look at the liburing implementation, it seems that io_uring_prep_read_fixed and io_uring_prep_readv are based on the same function io_uring_prep_rw, so if we done properly, it seems possible to perform socket read/write with flags set like recv/send.

But I think we need to decide how many buffers we want and how big they should be so that we can pre-allocate them

yeah, I also don't have a clear answer for this part..

  • How to determine the size of the fixed buffer? (as you mentioned, this depends heavily on the application)
  • What should happen when the fixed buffer becomes full?

I will consider these topics a bit more.

@armanbilge
Copy link
Owner Author

Related discussion, I think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants