LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-22-2004, 06:53 PM   #1
bstark
LQ Newbie
 
Registered: Nov 2004
Posts: 4

Rep: Reputation: 0
Non blocking file IO


I've noticed that opening a file in linux and setting the file descriptor to non blocking does not appear to work the way I would expect, I am seeing read and write calls block for up to 6 seconds waiting for a 65K write to complete. The aggregate IO rate for the RAID 0 I am doing IO to is reasonable, and the measurement mentioned above is rare, but I am using non blocking IO because I am in my server's execution state machine so I cannot afford to block that long. I have noticed that sockets under Linux work the way I expect. My solution will be to defer IO to separate threads so that I can maintain responsive service to clients. I was wondering if other developers have experienced similar issues with file IO under Linux and what solutions they may have come up with.

Brian
 
Old 11-23-2004, 04:43 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Are you talking about POSIX asynchronous I/O (aio_read(), aio_write(), etc)?

I think this may help what you are trying to do.
 
Old 11-23-2004, 05:00 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Quote:
O_NONBLOCK or O_NDELAY
When possible, the file is opened in non-blocking
mode. Neither the open nor any subsequent opera_
tions on the file descriptor which is returned will
cause the calling process to wait. For the han_
dling of FIFOs (named pipes), see also fifo(4).
This mode need not have any effect on files other
than FIFOs
.
Is that the problem you're having?
 
Old 11-24-2004, 10:52 AM   #4
bstark
LQ Newbie
 
Registered: Nov 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Yes, I'm not sure where the quote came from, but setting the O_NONBLOCKING flag has no effect on the descriptor of a regular file. What still bothers me is that I am seeing the write function block for up to 30 seconds for an 8000 byte write! Last night I saw roughly 15 times where a small write took over 10 seconds up to 30 seconds on one of my servers. This measurement is wrapped around a write function call. I can't help but think there is something very wrong here. Unfortunately, my background is in device drivers, so I'm used to being on the other end of the call.
 
Old 11-24-2004, 11:35 AM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
The quote came from man 2 open. I've never seen a write() function block noticeably on an 8k write. Are mutexes maybe involved somehow?
 
Old 12-01-2004, 12:36 PM   #6
bstark
LQ Newbie
 
Registered: Nov 2004
Posts: 4

Original Poster
Rep: Reputation: 0
File IO taking a long time

Thanks for the reply, I've been a way for a while. Last night I had a 40K (thats K not MB!) write take 38 seconds. The measurements I am getting are wrapped around a write call, so synchronization (at least at the application level) should not be the issue. The partition is configured as a RAID 0, and we are writing to 2-4 SATA drives. We are running Fedora core 2. The aggregate IO rate averages out to a reasonable value (30-60 MBS), but occasionally I see this anomaly. I'm concerned that using aio_write, or deferring my disk IO to separate threads may just be band-aiding a system level flaw in our overall architecture.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Blocking File Share port TheRealDeal Linux - Networking 1 01-14-2005 07:36 AM
IP Blocking Help mortsahl Linux - Security 2 04-26-2004 08:29 AM
IP blocking merlin371 Linux - Networking 2 08-04-2003 10:42 AM
Blocking X11 neil Linux - Security 9 02-04-2003 09:28 AM
Blocking file ext (exe, vbs, bat, com..) with sendmail PcHammer Linux - Software 2 08-29-2002 06:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration