News for hackers. Stuff that matters.
Re:Thread Pools in Nginx Boost Performance 9x (2015) by majke on Monday August 14, 2017 @07:12AM (#15007855)
Ok, I understand why you might "offload" read() from disk backed files file descriptors. But why "sendfile"? I thought sendfile is properly async in linux... Unless I'm getting something wrong.

"aio_write" -> wasn't the idea of AIO operations to actually be truly async? Maybe it's because it requires XFS. Anyway, I'm confused.

Re:Thread Pools in Nginx Boost Performance 9x (2015) by josefbacik on Monday August 14, 2017 @09:24AM (#15008385)
Sendfile isn't async, it just avoids the user space copy, and in some cases the copy from the fd to the socket. Aio doesn't require xfs, just O_DIRECT, which can be tricky to get right and more work than userspace guys want to deal with.
Re:Thread Pools in Nginx Boost Performance 9x (2015) by taf2 on Monday August 14, 2017 @07:46AM (#15007987)
From the article

"Although Linux provides a kind of asynchronous interface for reading files, it has a couple of significant drawbacks. One of them is alignment requirements for file access and buffers, but NGINX handles that well. But the second problem is worse. The asynchronous interface requires the O_DIRECT flag to be set on the file descriptor, which means that any access to the file will bypass the cache in memory and increase load on the hard disks. That definitely doesn’t make it optimal for many cases."

Re:Thread Pools in Nginx Boost Performance 9x (2015) by jsn on Monday August 14, 2017 @07:53AM (#15008016)
From what I can see, sendfile isn't really async, it still returns the number of bytes written or error status, and nginx probably needs to wait for that to e.g. log the results, handle short writes, or proceed with whatever next operation must be done to the socket (like closing it). No idea why aio_write needs offloading, though.
Re:Thread Pools in Nginx Boost Performance 9x (2015) by taf2 on Monday August 14, 2017 @07:58AM (#15008031)
They say why in the article

"The asynchronous interface requires the O_DIRECT flag to be set on the file descriptor, which means that any access to the file will bypass the cache in memory and increase load on the hard disks"

They even go into how no interface has been surfaced yet that allows determining whether a file is in cache or not. Also how FreeBSD's aio interface doesn't have the same limitations

Re:Thread Pools in Nginx Boost Performance 9x (2015) by dom0 on Tuesday August 15, 2017 @05:49PM (#15022990)
I never tried, but mmap and mincore could work (or not, as one of the many special cases in this area). I expect that's not a viable approach for this application, anyway :)
Re:Thread Pools in Nginx Boost Performance 9x (2015) by nemanjaboric on Monday August 14, 2017 @09:28AM (#15008410)
No, sendfile is not necessarily non-blocking (note the difference between async and non-blocking IO), it still blocks the caller if the reading side is a disk device. The advantage of using sendfile is that you need to copy the data from the kernel-space (source) to the user-space (program) and then back to the kernel-space.