apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 48557] New: file_io/unix/open.c:apr_file_open() should cache O_CLOEXEC support status
Date Fri, 15 Jan 2010 22:14:55 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=48557

           Summary: file_io/unix/open.c:apr_file_open() should cache
                    O_CLOEXEC support status
           Product: APR
           Version: HEAD
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: vapier@gentoo.org


Created an attachment (id=24850)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24850)
apr-1.3.9-assume-cloexec.patch

apr_file_open currently uses O_CLOEXEC when opening file's to avoid race
conditions with the classic behavior of then using fcntl() to set the
FD_CLOEXEC flag.  this is all find and dandy except that on newer operating
systems, the two fcntl() calls are still made even if the open() function
supports O_CLOEXEC.  when doing something like `svn commit` on a large tree,
these translates to a huge number of useless syscalls.

this should be easy to avoid -- if we called open() with O_CLOEXEC, and the
fcntl() get step shows that FD_CLOEXEC is already set, we cache the result in a
local variable.  then in all future steps, we check the cached value before
doing any fcntl() syscalls.

getting back to subversion, before my fix, a simple `svn st` looks something
like this:
......
open(".svn/entries", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "10\n\ndir\n9382\nsvn://nwd2cvs1.corp"..., 80) = 80
close(3)                                = 0
open(".svn/entries", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "10\n\ndir\n9382\nsvn://nwd2cvs1.corp"..., 4096) = 1187
read(3, "", 4096)                       = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
open("vendors/.svn/entries", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "10\n\ndir\n9382\nsvn://nwd2cvs1.corp"..., 80) = 80
close(3)                                = 0
......

and after, we see:
......
open(".svn/entries", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "10\n\ndir\n9382\nsvn://nwd2cvs1.corp"..., 80) = 80
close(3)                                = 0
open(".svn/entries", O_RDONLY|O_CLOEXEC) = 3
read(3, "10\n\ndir\n9382\nsvn://nwd2cvs1.corp"..., 4096) = 1187
read(3, "", 4096)                       = 0
read(3, "", 4096)                       = 0
close(3)                                = 0
open("vendors/.svn/entries", O_RDONLY|O_CLOEXEC) = 3
read(3, "10\n\ndir\n9382\nsvn://nwd2cvs1.corp"..., 80) = 80
close(3)                                = 0
......

when working on a repo with thousands of dirs/files, you can see how this
easily makes a significant difference.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message