X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-ID: <2570318aabfa537bf24c8d3a55f9dcd4.squirrel@www.webmail.wingert.org> In-Reply-To: <20100604045807.GC12167@ednor.casa.cgf.cx> References: <4C03D6C5 DOT 4050004 AT x-ray DOT at> <80373222dd5d43b134a5ede7036e7674 DOT squirrel AT www DOT webmail DOT wingert DOT org> <20100602080626 DOT GV16885 AT calimero DOT vinschen DOT de> <383c8b44a088dad09a0b77d3299feda7 DOT squirrel AT www DOT webmail DOT wingert DOT org> <20100602174848 DOT GA14172 AT ednor DOT casa DOT cgf DOT cx> <20100603235944 DOT GA12167 AT ednor DOT casa DOT cgf DOT cx> <20100604024422 DOT GB12167 AT ednor DOT casa DOT cgf DOT cx> <78e7b77657c0cfcd63dc22ad9679bc85 DOT squirrel AT www DOT webmail DOT wingert DOT org> <20100604045807 DOT GC12167 AT ednor DOT casa DOT cgf DOT cx> Date: Fri, 4 Jun 2010 09:37:18 -0700 Subject: Re: Cygwin Performance and stat() From: "Christopher Wingert" To: cygwin AT cygwin DOT com User-Agent: SquirrelMail/1.4.20 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 So here is an example of a performance gain by not using cygwin stat(). I did this patch in about an hour (with the help of some git code), so I wouldn't recommend it for any production use. On a dry run rsync from my local drive to my NAS (105GB, 34k files, 4k directories). The current release cygwin rsync did it in [36m:43s], with the patch (below) applied, it dropped to [04m:48s]. $ diff rsync-3.0.7-1/src/rsync-3.0.7/syscall.c fast-rsync-3.0.7-1/src/rsync-3.0.7/syscall.c 31a32,37 > // Get rid of a define for WINBOOL > #define __OBJC__ > #define WIN32_LEAN_AND_MEAN > #include > #include > 242a249 > printf( "doing [stat]\n" ); 249a257,277 > static inline time_t filetime_to_time_t(const FILETIME *ft) > { > long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; > winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */ > winTime /= 10000000; /* Nano to seconds resolution */ > return (time_t)winTime; > } > > static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts) > { > long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; > winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */ > ts->tv_sec = (time_t)(winTime/10000000); /* 100-nanosecond interval to seconds */ > ts->tv_nsec = (long)(winTime - ts->tv_sec*10000000LL) * 100; /* nanoseconds */ > } > > > > #define size_to_blocks(s) (((s)+511)/512) > > 251a280,344 > #if 1 > char path[ 1024 ]; > WIN32_FILE_ATTRIBUTE_DATA fdata; > int fMode; > > cygwin_conv_path( CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, fname, path, 1024 ); > > if ( GetFileAttributesEx( path, GetFileExInfoStandard, &fdata ) ) > { > // if ((fdata.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && > // !(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) > // return -1; > // printf( "GetFileAttributesEx() OK\n" ); > > if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) > fMode |= S_IFDIR; > else > fMode |= S_IFREG; > if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) > fMode |= S_IWRITE; > > st->st_ino = 0; > st->st_gid = st->st_uid = 0; > st->st_nlink = 1; > st->st_mode = fMode; > st->st_size = ((_off64_t)fdata.nFileSizeHigh << 32) + > fdata.nFileSizeLow; > st->st_blocks = size_to_blocks(st->st_size); > st->st_dev = st->st_rdev = 0; > filetime_to_timespec(&fdata.ftLastAccessTime, &st->st_atim); > filetime_to_timespec(&fdata.ftLastWriteTime, &st->st_mtim); > filetime_to_timespec(&fdata.ftCreationTime, &st->st_ctim); > errno = 0; > return 0; > } > else > { > // rsyserr(FERROR, errno, "GetFileAttributesEx() failed %s", path ); > // printf( "GetFileAttributesEx() FAILED\n" ); > errno = ENOENT; > return( -1 ); > } > > > switch (GetLastError()) > { > case ERROR_ACCESS_DENIED: > case ERROR_SHARING_VIOLATION: > case ERROR_LOCK_VIOLATION: > case ERROR_SHARING_BUFFER_EXCEEDED: > errno = EACCES; > break; > case ERROR_BUFFER_OVERFLOW: > errno = ENAMETOOLONG; > break; > case ERROR_NOT_ENOUGH_MEMORY: > errno = ENOMEM; > break; > default: > break; > } > > return( -1 ); > #endif > 264a358 > // printf( "doing [fstat]\n" ); -- 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