Even if only operations that *need* to be asynchronous require kernel threads, and even if they are recycled instead of being created and destroyed on demand, that will still be quite expensive at the kernel level.
If one thread per outstanding operation or per client is too many, there are good userspace thread pool implementations that dedicate a few threads to waiting for IO completions whilst others get on with whatever work can proceed immediately.
I'm not convinced that pushing the thread pool down into the kernel is a performance win.
The Linux thread implementation chose for very good reasons to stick to a 1:1 relationship between userspace and kernel threads: it's because the job of multiplexing application tasks to a smaller number of system threads is hard to do in a generic way. All the choices are best made by the application developer, therefore thread pool implementations belong in userspace.
I don't really see the point of supporting POSIX signal-driven AIO at the kernel level if the implementation uses threads and sits on top of the existing synchronous IO. A userspace library could do it just as reliably using select() and kill(), for those few applications that insist on the POSIX AIO interface for whatever reason.
That said, the kernel handles asynchronous events all the time. Why exactly is it so hard to let userspace handle them asynchronously too at a low level, without going through the synchronous layer?
I think the idea is to support AIO for all objects with a single API
Posted Apr 8, 2009 12:46 UTC (Wed) by khim (subscriber, #9252)
[Link]
While it's very important to have "light AIO" for some things (like TCP
sockets) it's not so important to have them for other things (like
in-memory pipes). If you have everything in kernel you can implement some
things with threads and other without threads and userspace does not care.
With userspace library any change require ABI schange - and that's
PAIN...