【问题标题】:why is cygwin so slow为什么cygwin这么慢
【发布时间】:2012-06-17 10:20:29
【问题描述】:

我在 Ubuntu 上运行了一个脚本,并测试了它的时间:

$ time ./merger
./merger  0.02s user 0.03s system 99% cpu 0.050 total

它花费了不到 1 秒的时间。 但如果我使用 cygwin:

$ time ./merger
real    3m22.407s
user    0m0.367s
sys     0m0.354s

耗时超过 3 分钟。 为什么会这样?如何提高cygwin的执行速度?

【问题讨论】:

  • 与 Linux 相比,Windows 上的生成进程非常慢 - cygwin 无法解决这个限制。
  • 检查this是否有帮助。
  • 这不仅仅是进程的产生,而是fork 的模拟使Cygwin 如此缓慢。 fork 是 Win32 API 本身不支持的东西,所以它必须做很多hackery 和复制才能获得与 POSIX 下相同的效果(通常这是通过复制页表并使页面复制来完成 - on-write,就是这样)。
  • 你能给我们看看代码吗?你用什么语言?它是一个 bash 脚本吗?它有一个大循环吗?没有更多信息很难帮助你,@PaulR 是对的,AFAIK 分叉很慢,在某些情况下甚至经常失败
  • How to speed up Cygwin?的可能重复

标签: linux cygwin


【解决方案1】:

正如其他人已经提到的,Cygwin's implementation 在 Windows 上的 fork 和进程生成通常很慢。

使用this fork() benchmark,我得到以下结果:

rr-@cygwin:~$ ./test 1000
Forked, executed and destroyed 1000 processes in 5.660011 seconds.

rr-@arch:~$ ./test 1000
Forked, executed and destroyed 1000 processes in 0.142595 seconds.

rr-@debian:~$ ./test 1000
Forked, executed and destroyed 1000 processes in 1.141982 seconds.

使用time (for i in {1..10000};do cat /dev/null;done) 对进程生成性能进行基准测试,我得到以下结果:

rr-@work:~$ time (for i in {1..10000};do cat /dev/null;done)
(...) 19.11s user 38.13s system 87% cpu 1:05.48 total

rr-@arch:~$ time (for i in {1..10000};do cat /dev/null;done)
(...) 0.06s user 0.56s system 18% cpu 3.407 total

rr-@debian:~$ time (for i in {1..10000};do cat /dev/null;done)
(...) 0.51s user 4.98s system 21% cpu 25.354 total

硬件规格:

  • cygwinIntel(R) Core(TM) i7-3770K CPU @ 3.50GHz
  • 拱门Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
  • debianIntel(R) Core(TM)2 Duo CPU T5270 @ 1.40GHz

因此,如您所见,无论您使用什么,Cygwin 都会运行得更差。它甚至会在更差的硬件上失手(cygwindebian 在此基准测试中,根据 this comparison)。

【讨论】:

    猜你喜欢
    • 2021-09-03
    • 2016-09-28
    • 2020-02-08
    • 2012-07-17
    • 2011-11-07
    • 2015-08-24
    • 2013-08-06
    • 2014-07-16
    • 2011-01-02
    相关资源
    最近更新 更多