Mail Archives: cygwin/2010/06/07/04:46:58
On Jun 5 08:43, Christopher Wingert wrote:
> So... the person who cared to improve his/her/its code would say, "Well
> we use NTOpenFile() because it does the blah blah extra functionality that
> FindNextFile()/GetFileAttributes() do not." Then we could look to other
> Win32 APIs to try to achieve those results.
As you can see in the source code, the Cygwin file access functions are
using the native NT API, rather than the Win32 API.
> For example opening a file on Windows for the purposes of stat()ing a file
> is dumb, considering the way most Windows Virus Scanners work.
That's not correct. The Win32 functions are implemented in terms of
native NT functions, and the native NT functions have to open the file
to fetch information. For instance, the function you're using in your
test code, GetFileAttributesEx, is probably actually implemented along
the lines of
HANDLE h;
NtOpenFile (&h, "File");
NtQueryInformationFile (h, ..., FileAllInformation, ...);
NtClose (h);
Alternatively
HANDLE h;
NtOpenFile (&h, "ParentDirectory");
NtQueryInformationFile (h, ..., FileDirectoryInformation, ...);
NtClose (h);
Just because the Win32 API doesn't require the application to open
the file doesn't mean it doesn't require it under the hood.
Having said that, there is obviously some reason why Cygwin's stat is
slow. I'll have a look into it at some point.
What would be really cool would be if somebody could make some real
profiling, so we could get a hunch where to look first.
For instance, I have a vague feeling that we can raise the performance
by avoiding the long call chain of the stat call
stat64
stat_worker
fhandler_disk_file::fstat
fhandler_base::fstat_fs
fhandler_base::fstat_by_handle
fhandler_base::fstat_helper
get_file_attribute
get_info_from_sd
given our experience with the call chain of the wctomb sort of
functions. But that's certainly not the only knob we could play with.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -