Cygwin文件打开缓慢

8
我的应用程序使用fopen打开很多文件。在Linux中,打开和读取成千上万个文件甚至不需要一秒钟;但在Cygwin中,需要超过5秒钟。
我认为这是因为Cygwin dll中的路径转换函数。'open'函数稍微快一些。如果我使用-mno-cygwin,它会变得非常快,但我不能使用它。
有没有一种简单的方法可以使Cygwin dll仅打开文件,而没有任何Linux-Windows转换?
1个回答

7
这取决于系统在Cygwin环境中的安装方式。
$ 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)

挂载选项"binary"使得从卷中读取的文件不进行CRLF <-> LF转换。这是默认设置。

以下是加速Cygwin提示的一些方法:

  1. 将以下行添加到您的~/.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. 断开网络驱动器的连接。

  2. 禁用您的防病毒软件,或者将Cygwin文件夹从扫描范围中排除。

彻底的防病毒程序会在程序打开文件时扫描恶意软件,这意味着如果您的脚本正在打开成千上万个文件,则它将加倍努力工作。

  1. 运行autotools configure脚本时使用选项--cache-file="$HOME/.config.cache"

这将创建一个包含预先记录的配置发现的文件,其中大部分可在软件构建之间使用。(在使用Linux时,这也是一个好主意)。

由于shell似乎是Cygwin系统的瓶颈,依赖于启动大量进程的巨大脚本将花费很长时间,这将减少它需要启动的进程数。

  1. 设置Cygwin的sshd并停止使用Windows命令提示符,改用PuTTY。

PuTTY对屏幕上的文本更具响应性,因为它是为更成熟的*NIX CLI界面而构建的。


还有一个叫做puttycyg的工具:http://code.google.com/p/puttycyg/ 它可以让你在Cygterm中使用putty。 - dbellizzi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接