如何让Windows在编译C ++时像Linux一样快? [英] How do I get Windows to go as fast as Linux for compiling C++?

查看:230
本文介绍了如何让Windows在编译C ++时像Linux一样快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这不是一个编程问题,但它是相关的。

I know this is not so much a programming question but it is relevant.

我工作在一个相当大型跨平台项目。在Windows上我使用VC ++ 2008.在Linux上我使用gcc。项目中有大约40k个文件。在编译和链接同一项目时,Windows比Linux慢10倍到40倍。

I work on a fairly large cross platform project. On Windows I use VC++ 2008. On Linux I use gcc. There are around 40k files in the project. Windows is 10x to 40x slower than Linux at compiling and linking the same project. How can I fix that?

在Linux上单次更改增量构建20秒,在Windows上大于3分钟。为什么?我甚至可以在Linux中安装'gold'链接器,并将时间缩短到7秒。

A single change incremental build 20 seconds on Linux and > 3 mins on Windows. Why? I can even install the 'gold' linker in Linux and get that time down to 7 seconds.

同样,git在Linux上比Windows快10倍到40倍。

Similarly git is 10x to 40x faster on Linux than Windows.

在git的情况下,git可能不是以最佳方式使用Windows,但是VC ++?你会认为微软会想让自己的开发人员尽可能高效,并且更快的编译将会有很长的路要走。也许他们试图鼓励开发人员进入C#?

In the git case it's possible git is not using Windows in the optimal way but VC++? You'd think Microsoft would want to make their own developers as productive as possible and faster compilation would go a long way toward that. Maybe they are trying to encourage developers into C#?

作为简单的测试,找到一个包含大量子文件夹的文件夹,并做一个简单的

As simple test, find a folder with lots of subfolders and do a simple

dir /s > c:\list.txt

做它两次和时间第二次运行,所以它从缓存运行。将文件复制到Linux并执行等效的2次运行和第二次运行时间。

on Windows. Do it twice and time the second run so it runs from the cache. Copy the files to Linux and do the equivalent 2 runs and time the second run.

ls -R > /tmp/list.txt

我有两个具有完全相同规格的工作站。 HP Z600s配备12gig的RAM,8个内核,3.0GHz。在具有〜400k文件的文件夹中,Windows需要40秒, 1秒。

I have 2 workstations with the exact same specs. HP Z600s with 12gig of ram, 8 cores at 3.0ghz. On a folder with ~400k files Windows takes 40seconds, Linux takes < 1 second.

有没有注册表设置可以设置为加速Windows?

Is there a registry setting I can set to speed up Windows? What gives?

推荐答案

除非有硬核Windows系统黑客,否则你不会得到比党派的评论

Unless a hardcore Windows systems hacker comes along, you're not going to get more than partisan comments (which I won't do) and speculation (which is what I'm going to try).


  1. 文件系统 - 你应该在同一个文件系统上尝试相同的操作(包括 dir )。我遇到了这个,其中对各种参数的几个文件系统进行了基准测试。

  1. File system - You should try the same operations (including the dir) on the same filesystem. I came across this which benchmarks a few filesystems for various parameters.

缓存。我曾试图在Linux上的RAM磁盘上运行一个编译,发现它比在磁盘上运行它慢,因为内核负责缓存的方式。这是Linux的一个坚实的卖点,可能是为什么性能如此不同的原因。

Caching. I once tried to run a compilation on Linux on a RAM disk and found that it was slower than running it on disk thanks to the way the kernel takes care of caching. This is a solid selling point for Linux and might be the reason why the performance is so different.

Windows上的依赖关系规格不正确。也许Windows的铬依赖规范不如Linux的正确。这可能会导致不必要的编译,当你做一个小的改变。您可以使用Windows上的相同编译器工具链来验证此情况。

Bad dependency specifications on Windows. Maybe the chromium dependency specifications for Windows are not as correct as for Linux. This might result in unnecessary compilations when you make a small change. You might be able to validate this using the same compiler toolchain on Windows.

这篇关于如何让Windows在编译C ++时像Linux一样快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆