diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2016-02-10 15:47:44 -0500 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2016-02-11 09:01:33 +1100 |
commit | d7a7ed74d439fb0a1adcd003c81b90eab0de20ca (patch) | |
tree | 074cf602fc67db8af422d4270a05a83f98db30b7 /win32/win32.c | |
parent | 3066fc02265b48aeccdd8e86abc86cd0b18975cd (diff) | |
download | perl-d7a7ed74d439fb0a1adcd003c81b90eab0de20ca.tar.gz |
add shortcut around syscalls when file not found in win32_stat
win32_stat on success makes ~7 system calls, some from perl, some from CRT,
but on failure, typically file not found, the perl syscalls fails, then the
CRT stat runs, and fails too, so 5 mostly failing system calls are done
for file not found. If the perl syscall says file not found, the
file wont magically come into existence in the next 10-1000 us for the
CRT's syscalls, so skip calling the CRT and the additional syscalls
if the perl didn't find the file. This patch reduces the number of syscalls
from 5 to 1 for file not found for a win32 perl stat. Benchmark and
profiling info is attached to RT ticket for this patch. Note CreateFile on
a dir fails with ERROR_ACCESS_DENIED so in some cases, a failed CreateFile
is still a successful CRT stat() which does things differently so dirs can
be opened.
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c index b410f662cd..651b97b417 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1514,6 +1514,14 @@ win32_stat(const char *path, Stat_t *sbuf) nlink = bhi.nNumberOfLinks; CloseHandle(handle); } + else { + DWORD err = GetLastError(); + /* very common case, skip CRT stat and its also failing syscalls */ + if(err == ERROR_FILE_NOT_FOUND) { + errno = ENOENT; + return -1; + } + } } /* path will be mapped correctly above */ |