开发者

cygwin slow file open

My application uses fopen to open a lot of files. While in linux opening and reading thousand of files doesn't even take a second; in cygwin it takes more than 5 seconds.

I think it is because path conversion functions in cygwin dlls. 'open' function is a bit faster. If I use -mno-cygwin it becomes very fast but I can't use it.

Is there an e开发者_如何学Casy way to make cygwin dlls just open files; without any linux-windows conversion?


It depends on how the system was mounted in the Cygwin environment.

$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type iso9660 (binary,posix=0,user,noumount,auto)

The mount option "binary" makes it so CRLF <-> LF conversions are not performed on files read from the volume. This is default.

Some things you can do to speed up a Cygwin prompt are the following:

  1. Add the following lines to your ~/.bashrc:
# eliminate long Windows pathnames from the PATH
export PATH='/bin:/usr/bin:/usr/local/bin'

# check the hash before searching the PATH directories
shopt -s checkhash

# do not search the path when .-sourcing a file
shopt -u sourcepath
  1. Disconnect your network drives.

  2. Disable your antivirus, or otherwise exclude Cygwin's folders from its scans.

Thorough antivirus programs scan files for malware as they're opened by programs, and this means it'll be working overtime if your script is opening thousands of files.

  1. Use the option --cache-file="$HOME/.config.cache" when running autotools configure scripts.

This will create a file that holds prerecorded configure discoveries, most of which are usable between software builds. (This is also a good idea when using Linux).

Since the shell seems to be the bottleneck of the Cygwin system, a huge script that relies on starting a large number of processes will take forever and this will cut down on the number of processes it needs to start.

  1. Set up Cygwin's sshd and stop using Windows Command Prompt in favor of PuTTY.

PuTTY responds better to changing text on the screen, as it was built for the more mature CLI interface of *NIX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜