Changeset 232088 in webkit


Ignore:
Timestamp:
May 22, 2018 4:54:04 PM (6 years ago)
Author:
Chris Dumez
Message:

[POSIX] Use access() instead of stat() in FileSystem::fileExists()
https://bugs.webkit.org/show_bug.cgi?id=185882

Reviewed by Geoffrey Garen.

Use access() instead of stat() in FileSystem::fileExists(). stat() returns a lot of information we
do not leverage and local benchmarking on macOS shows access() being > 80% faster than stat():
stat: 0.31567 (lower is better)
access: 0.16074 (lower is better)
stat: 0.303665 (lower is better)
access: 0.165468 (lower is better)

  • platform/posix/FileSystemPOSIX.cpp:

(WebCore::FileSystem::fileExists):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r232081 r232088  
     12018-05-22  Chris Dumez  <cdumez@apple.com>
     2
     3        [POSIX] Use access() instead of stat() in FileSystem::fileExists()
     4        https://bugs.webkit.org/show_bug.cgi?id=185882
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Use access() instead of stat() in FileSystem::fileExists(). stat() returns a lot of information we
     9        do not leverage and local benchmarking on macOS shows access() being > 80% faster than stat():
     10        stat: 0.31567 (lower is better)
     11        access: 0.16074 (lower is better)
     12        stat: 0.303665 (lower is better)
     13        access: 0.165468 (lower is better)
     14
     15        * platform/posix/FileSystemPOSIX.cpp:
     16        (WebCore::FileSystem::fileExists):
     17
    1182018-05-22  Brent Fulgham  <bfulgham@apple.com>
    219
  • trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp

    r230639 r232088  
    5959        return false;
    6060
    61     struct stat fileInfo;
    62 
    63     // stat(...) returns 0 on successful stat'ing of the file, and non-zero in any case where the file doesn't exist or cannot be accessed
    64     return !stat(fsRep.data(), &fileInfo);
     61    return access(fsRep.data(), F_OK) != -1;
    6562}
    6663
Note: See TracChangeset for help on using the changeset viewer.