Replies: 1 comment 4 replies
-
The cqring and sqring barely use any memory, only 16 bytes per cqe and 64 bytes per sqe. If you had the maximum size for both rings, you'd only end up using about 3 megabytes. That's not really what matters though, as the ring size does not limit how many I/O requests you can submit. The rings are only the communication layer between userspace and kernel space, eliminating a memory copy (one which aio and epoll do). It matters more how many simultaneous outstanding I/O you are performing, as the kernel has to allocate a request for each sqe and can only release it once the request finishes. Personally, I'd suggest using a sqring size of 256 or 512, which ever one performs better for you, and submit every time the ring fills up. This has a very good balance between number of syscalls and I/O latency (you want to start the requests as early as possible so that you can get a completion as soon as possible). The cqring you can make as big as you want, but make it especially big if you are handling lots of I/O. If the cqring overflows, the kernel has to allocate an overflow entry to store your result and creates extra overhead. |
Beta Was this translation helpful? Give feedback.
-
I had asked a question earlier #591 . Wanted some more clarification on the same.
So, I want to understand what amount of memory is allocated (be it in kernel space or userspace) when I ask for a thread to create uring of size 1K entries ? Reading documentation about io_uring_mlock_size it seems to suggest that only that memory which will be mlock’ed will be accounted by this API. Besides in newer kernels this will return zero.
Is there a better API to get the memory requirements for a particular ring size ?
The reason I need to understand the memory requirements is to make an informed decision about what the ideal uring size should be for my application.
Beta Was this translation helpful? Give feedback.
All reactions