mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* slow open() calls and o_nonblock
@ 2007-06-03 18:52 Aaron Wiebe
  2007-06-03 19:16 ` Davide Libenzi
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Aaron Wiebe @ 2007-06-03 18:52 UTC (permalink / raw)
  To: linux-kernel

Greetings all.  I'm not on this list, so I apologize if this subject
has been covered before.  (Also, please cc me in the response.)

I've spent the last several months trying to work around the lack of a
decent disk AIO interface.  I'm starting to wonder if one exists
anywhere.  The short version:

I have written a daemon that needs to open several thousand files a
minute and write a small amount of data to each file.  After extensive
research, I ended up going with the POSIX AIO kludgy pthreads wrapper
in glibc to handle my writes due to the time constraints of writing my
own pthreads handler into the application.

The problem with this equation is that opens, closes and non-readwrite
operations (fchmod, fcntl, etc) have no interface in posix aio.  Now I
was under the assumption that given open and close operations are
comparatively less common than the write operations, this wouldn't be
a huge problem.  My tests seemed to reflect that.

I went to production with this yesterday to discover that under
production load, our filesystems (nfs on netapps) were substantially
slower than I was expecting.  open() calls are taking upwards of 2
seconds on occation, and usually ~20ms.

Now, Netapp speed aside, O_NONBLOCK and O_DIRECT seem to make zero
difference to my open times.  Example:

open("/somefile", O_WRONLY|O_NONBLOCK|O_CREAT, 0644) = 1621 <0.415147>

Now, I'm a userspace guy so I can be pretty dense, but shouldn't a
call with a nonblocking flag return EAGAIN if its going to take
anywhere near 415ms?  Is there a way I can force opens to EAGAIN if
they take more than 10ms?

Thanks for any help you folks can offer.

-Aaron Wiebe

(ps.  having come from the socket side of the fence, its incredibly
frustrating to be unable to poll() or epoll regular file FDs --
Especially knowing that the kernel is translating them into a TCP
socket to do NFS anyway.  Please add regular files to epoll and give
me a way to do the opens in the same fasion as connects!)

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: slow open() calls and o_nonblock
@ 2007-06-04  3:57 Albert Cahalan
  0 siblings, 0 replies; 22+ messages in thread
From: Albert Cahalan @ 2007-06-04  3:57 UTC (permalink / raw)
  To: linux-kernel, davids, epiphani, viro

David Schwartz writes:
> [Aaron Wiebe]

>> open("/somefile", O_WRONLY|O_NONBLOCK|O_CREAT, 0644) = 1621 <0.415147>
>
> How could they make any difference? I can't think of any
> conceivable way they could.
>
>> Now, I'm a userspace guy so I can be pretty dense, but shouldn't a
>> call with a nonblocking flag return EAGAIN if its going to take
>> anywhere near 415ms?  Is there a way I can force opens to EAGAIN if
>> they take more than 10ms?
>
> There is no way you can re-try the request. The open must either
> succeed or not return a handle. It is not like a 'read' operation
> that has an "I didn't do anything, and you can retry this request"
> option.
>
> If 'open' returns a file handle, you can't retry it (since it must
> succeed in order to do that, failure must not return a handle).
> If you 'open' doesn't return a file handle, you can't retry it
> (because, without a handle, there is no way to associate a future
> request with this one, if it creates a file, the file must not be
> created if you don't call 'open' again).
>
> The 'open' function must, at minimum, confirm that the file exists
> (or doesn't exist and can be created, or whatever). This takes
> however long it takes on NFS.

This is not the case, though we might need to allocate a new
flag to avoid breaking things.

Let open() with O_UNCHECKED always return a file descriptor,
except perhaps when failure can be identified without doing IO.
The "real" open then proceeds in the background.

>From poll() or select(), you can see that the file descriptor
is not ready for anything. Eventually it becomes ready for IO
or reports an error condition. Both select() and poll() are
capable of reporting errors. If the "real" (background) open()
fails, then the only valid operation is close(). Attempts to
do anything else get EBADFD or ESTALE.

You'll also need a background close().

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2007-06-04 20:34 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-03 18:52 slow open() calls and o_nonblock Aaron Wiebe
2007-06-03 19:16 ` Davide Libenzi
2007-06-03 23:56 ` John Stoffel
2007-06-04  1:05   ` Aaron Wiebe
2007-06-04  1:20     ` Neil Brown
2007-06-04 13:59       ` Aaron Wiebe
2007-06-04  1:25     ` Bernd Eckenfels
2007-06-04  0:27 ` David Schwartz
2007-06-04  1:05   ` Al Viro
2007-06-04  1:19 ` Bernd Eckenfels
2007-06-04 13:49 ` Alan Cox
2007-06-04 14:04   ` Aaron Wiebe
2007-06-04 14:17     ` John Stoffel
2007-06-04 14:24       ` Aaron Wiebe
2007-06-04 14:20 ` Aaron Wiebe
2007-06-04 15:42   ` Trond Myklebust
2007-06-04 15:59     ` Aaron Wiebe
2007-06-04 16:26       ` Aaron Wiebe
2007-06-04 19:46         ` Trond Myklebust
2007-06-04 20:32   ` David Schwartz
2007-06-04 14:39 ` Aaron Wiebe
2007-06-04  3:57 Albert Cahalan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®