delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/06/07/04:46:58

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 <corinna-cygwin AT cygwin DOT com>
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> <b8832ccca61b1d5a1e3dba6d087b3a5b DOT squirrel AT www DOT webmail DOT wingert DOT org>
MIME-Version: 1.0
In-Reply-To: <b8832ccca61b1d5a1e3dba6d087b3a5b.squirrel@www.webmail.wingert.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019