News for hackers. Stuff that matters.
Re:Two new ways to read a file quickly by koolba on Friday March 06, 2020 @10:01PM (#22509438)
The problem is that the calls are related. The first gives you the file handle, the second reads it, the third closes it. You need the handle in advance to queue the second and third.

This idea reminds me of pipelined Redis commands. It does work to boost total throughout, but it’s significantly more complicated to use in practice.

Re:Two new ways to read a file quickly by jzwinck on Friday March 06, 2020 @10:45PM (#22509607)
Imagine a method like this:

    1. Enqueue A = openat(...)
    2. Enqueue B = read(A, buf, sz)
    3. Enqueue close(A)
    4. Commit, return B to userspace
A and B are placeholders, and A is never known to userspace, it is simply chained within the enqueued commands.
Re:Two new ways to read a file quickly by danobi on Friday March 06, 2020 @11:01PM (#22509645)
What if openat() or read() fails? More generally, what if there's a chain of syscalls and you _want_ one of them to fail?
Re:Two new ways to read a file quickly by JoshTriplett on Saturday March 07, 2020 @12:44AM (#22510006)
With the "specific fd" approach, if openat fails, then read and close will harmlessly fail with EBADF ("Bad file descriptor"). Once you process the failure of openat, you'll just ignore the failure of read and close.
Re:Two new ways to read a file quickly by yxhuvud on Saturday March 07, 2020 @02:42AM (#22510392)
What will happen though, if the fd is already used by some other area of userspace? Like what if some lib you link to also happen to hardcore the use of the same fd. Sounds like unfunny problems to debug.

In the case of uring I suppose it is possible to link the calls to fail at the first failure.

Re:Two new ways to read a file quickly by JoshTriplett on Saturday March 07, 2020 @03:15AM (#22510512)
> What will happen though, if the fd is already used by some other area of userspace?

That's what the min_fd patch is for, and potentially other systems for reserving blocks of fds. Much like memory, you'll ask the kernel for a block of it and then do your own allocations out of that.

Re:Two new ways to read a file quickly by yxhuvud on Saturday March 07, 2020 @11:57AM (#22512532)
Ah, it will be possible to allocate multiple blocks of file descriptors? Ok, then things start to make sense.
Re:Two new ways to read a file quickly by riffraff on Saturday March 07, 2020 @12:22AM (#22509924)
This seems exactly the io_uring approach with magic fd described in the article.
Re:Two new ways to read a file quickly by naasking on Saturday March 07, 2020 @09:18AM (#22511618)
> You need the handle in advance to queue the second and third.

Think about how pipelined commands work in a command shell if you want to understand how to construct a program that can define a sequence of operations on objects before they're defined.

Re:Two new ways to read a file quickly by correct_horse on Friday March 06, 2020 @10:18PM (#22509505)
> You need the handle in advance to queue the second and third

whoops. I probably should have thought of that.