io_uring_reg..._max_workers(3)

πŸ’… io_uring_reg..._max_workers β€” bestie edition

okay so the actual manual page is io_uring_reg..._max_workers(3) and it lives in the liburing Manual, and bestie, it is SO much more chill than it sounds. let's get into it 🫢


✨ NAME ✨

io_uring_register_iowq_max_workers β€” modify the maximum allowed async workers 🧚


🌸 SYNOPSIS 🌸

#include <liburing.h>

int io_uring_register_iowq_max_workers(struct io_uring *ring,
                                       unsigned int *values);

πŸ’– DESCRIPTION πŸ’–

okay so first thing's first: io_uring async workers? they come in two whole flavors, and you have to know the difference or nothing makes sense. no cap.

  • Bounded β€” these workers have a bounded execution time. like, they know when they're gonna be done. examples of this are filesystem reads, which normally complete in a relatively short amount of time. and even if the disk is being a whole mess and failing? they're still bounded by a timeout operation that will abort them if it's exceeded. so they're on a leash. πŸ”₯
  • Unbounded β€” work items here may take an indefinite amount of time to complete. examples include doing IO to sockets, pipes, or any other non-regular type of file. these ones are out here living their main character life with no end date in sight. πŸ’€

so what are the defaults, you ask? bestie. by default, the amount of bounded IO workers is limited to how many SQ entries the ring was setup with, or 4 times the number of online CPUs in the system β€” whichever is smaller. and unbounded workers? those are only limited by the process task limit, as indicated by the rlimit RLIMIT_NPROC limit. that's it. that's the whole ceiling. 😭


this can be modified by calling io_uring_register_iowq_max_workers with ring set to the ring in question, and values pointing to an array of two values. the first element should contain the number of desired bounded workers, and the second element should contain the number of desired unbounded workers. πŸ’«

and listen β€” these are both maximum values. io_uring will not maintain a high count of idle workers, they are reaped when they are not necessary anymore. it's giving "we hire when we need you, we don't keep you on the payroll for vibes". ✨

πŸŽ€ if called with both values set to 0, the existing values are returned.

πŸ”₯ RETURN VALUE πŸ”₯

returns 0 on success, with values containing the previous values for the settings. yay! πŸ’–

on error, any of the following may be returned:

  • -EFAULT β€” the kernel was unable to copy the memory pointer to by values as it was invalid. the pointer said "trust me" and lied. πŸ™ˆ
  • -EINVAL β€” values was NULL or the new values exceeded the maximum allowed value. nope, that's too much, absolutely not. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


that's the whole page bestie, go forth and register those workers, slay, periodt πŸ¦‹πŸ’…πŸŒˆ

sign-off moment: this was liburing-2.2, dated March 13, 2022 β€” from the liburing Manual. mwah. πŸŽ€β­πŸ’œ

πŸ“¦ where this page comes from