This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5742] New: stdio poor file buffering in "w+b" mode


Opening a file with mode "w+b" and then doing repetetive fseek() and fwrite()
calls will result in pointless read() calls to the kernel. The output of
'strace' on the process looks like this:

_llseek(3, 2424832, [2424832], SEEK_SET) = 0
read(3, "\0`\374\267\1\0\0\0E\3\0"..., 32768) = 14848
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0"..., 2560) = 2560
_llseek(3, 2424832, [2424832], SEEK_SET) = 0
read(3, "\0`\374\267\1\0\0\0E\3\0\0"..., 32768) = 17408
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2560) = 2560

yet there are no fread() calls of any kind in the program. The reads are not
only useless, they trigger a catastrophic slowdown when this is done over nfs
with recent linux kernels, as reported in:
http://bugzilla.kernel.org/show_bug.cgi?id=9566

I also checked glibc 2.7 and 2.7-20080204 and both have the exact same behavior.
Note that the above strace is for a file on nfs; on a local filesystem glibc
appears to use a smaller buffer but the read() calls are still there.

-- 
           Summary: stdio poor file buffering in "w+b" mode
           Product: glibc
           Version: 2.3.6
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: olivier dot paquet at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i486-slackware-linux
  GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=5742

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]