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 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: <20100530170747 DOT GA8605 AT ednor DOT casa DOT cgf DOT cx> <20100530210321 DOT GB11159 AT ednor DOT casa DOT cgf DOT cx> In-Reply-To: <20100530210321.GB11159@ednor.casa.cgf.cx> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 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