X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Mon, 7 Jun 2010 10:46:38 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Cygwin Performance and stat() Message-ID: <20100607084638.GD8163@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20100605052429 DOT GA4801 AT ednor DOT casa DOT cgf DOT cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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