delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/05/30/17:53:01

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=2.6 required=5.0 tests=AWL,BAYES_50,FH_HAS_XID,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY
X-Spam-Check-By: sourceware.org
Message-ID: <4C02DE2D.90600@t-online.de>
Date: Sun, 30 May 2010 23:52:45 +0200
From: Christian Franke <Christian DOT Franke AT t-online DOT de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 SeaMonkey/2.0.4
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Cygwin Performance and stat()
References: <efe8a37b2e4466daa7b6eb1aa610c3d7 DOT squirrel AT www DOT webmail DOT wingert DOT org> <20100530170747 DOT GA8605 AT ednor DOT casa DOT cgf DOT cx> <f460895a8fc53da26cb91259a4005da2 DOT squirrel AT www DOT webmail DOT wingert DOT org> <20100530210321 DOT GB11159 AT ednor DOT casa DOT cgf DOT cx>
In-Reply-To: <20100530210321.GB11159@ednor.casa.cgf.cx>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

Christopher Faylor wrote:
> On Sun, May 30, 2010 at 12:51:31PM -0700, Christopher Wingert wrote:
>    
>> I assume POSIX compatibility.  However, I bet there are cases where one
>> can sacrifice compatibility for performance (configurable with an
>> environment flag of course).
>>
>>      

The problem is that POSIX stat() requires to provide all information in 
struct stat. This is expensive: convert ACL into mode, convert filetimes 
into time_t, lookup uids, invent ino, ....
Typically applications don't need all info but there is no way to tell 
this to stat().


>> See
>>
>> http://marc.info/?l=git&m=122278284210941
>>
>> for an example.
>>      
> Yes, I got what you meant.  I think that bypassing Cygwin, assuming you
> can do something good enough is a remarkably bad idea.
>
>    

A probably better idea would be to add another stat() variant (this is 
IMO missing in POSIX) to Cygwin which allows to specify which info is 
needed.

Something like:

enum {
   CYGSTAT_MODE = 0x01,
   CYGSTAT_INO = 0x02,
   CYGSTAT_SIZE = 0x04,
   CYGSTAT_ATIME = 0x08,
   ...
};

int cygwin_stat4(const char *path, struct stat *buf, unsigned needed, 
unsigned *pvalid);

Where 'needed' contains all CYGSTAT_* flags for the stat fields needed. 
If 'pvalid' is != 0, the flags for the valid fields are returned in the 
variable. This can be a superset of 'needed' if some info is available 
for free.

Usage example:

// Get st_size only.
#ifdef __CYGWIN__
#define stat_size(p, b) cygwin_stat4(p, b, CYGSTAT_SIZE, NULL)
#else
#define stat_size(p, b) stat(p, b)
#endif

Christian


--
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