delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/02/13/18:29:12

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3A89C304.89BD74A0@etr-usa.com>
Date: Tue, 13 Feb 2001 16:28:04 -0700
From: Warren Young <warren AT etr-usa DOT com>
Organization: -ENOENT
X-Mailer: Mozilla 4.74 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Cygwin-L <cygwin AT cygwin DOT com>
Subject: Re: Optimizing away "ReadFile" calls when Make calls stat()
References: <4 DOT 3 DOT 1 DOT 2 DOT 20010213134821 DOT 019a7130 AT pop DOT ma DOT ultranet DOT com> <20010213190131 DOT 14369 DOT qmail AT lizard DOT curl DOT com> <200102131935 DOT OAA09136 AT envy DOT delorie DOT com> <20010213194612 DOT 17311 DOT qmail AT lizard DOT curl DOT com>

jik-cygwin AT curl DOT com wrote:
> 
> As I've noted separately, reading tens of thousands of files even once
> incurs a significant performance penalty.  The change I've proposed
> can eliminate reading them at all.

Even stat() under Linux does at least one disk read.  You can't
completely optimize away disk I/O for stat().

The main culprit is that this is one of many places where Unix doesn't
map onto Win32 well at all.  The VC++ RTL doesn't use ReadFile() to
implement _stat() at all.  When it checks for things like stat.st_mode
== S_IEXEC, it simply checks the filename extension for .exe, .com or
.bat.  Cygwin can't do that -- it must look at the file's magic bytes to
see if it's an executable, or a #! style script.  

stat() on Unixen doesn't do either of these things; all the info stat()
reports is in the inode.  The info in a prototypical Unix inode is
scattered in many different places in Win32, which makes the emulator
for a call like stat() slow.

Maybe a better optimization strategy would be to patch GNU Make. 
Wherever it does a stat() to find the modification time, do something
like this:

        struct stat st;
#ifdef CYGWIN
        WIN32_FIND_DATA findinfo;
        HANDLE h = FindFirstFile(filename, &findinfo);
        st.st_mtime = findinfo.ftLastWriteTime;
        FindClose(h);
#else
        stat(filename, &st);
#endif

(ftLastWriteTime will probably need translation into a time_t, but
that's a small matter.)
--                                                   _
= 'Net Address: http://www.cyberport.com/~tangent | / \  ASCII Ribbon
= ICBM Address: 36.82740N, 108.02040W, alt. 1714m | \ /  Campaign
=                                                 |  X   Against
= Chance favors the prepared mind.                | / \  HTML Mail

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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