How do I get Windows to go as fast as Linux for compiling C++?

后端 未结 13 1034
生来不讨喜
生来不讨喜 2020-12-22 15:14

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

I work on a fairly large cross platform project. On Windows I use VC++ 2008. On Linux I use gcc

13条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 15:54

    IMHO this is all about disk I/O performance. The order of magnitude suggests a lot of the operations go to disk under Windows whereas they're handled in memory under Linux, i.e. Linux is caching better. Your best option under windows will be to move your files onto a fast disk, server or filesystem. Consider buying an Solid State Drive or moving your files to a ramdisk or fast NFS server.

    I ran the directory traversal tests and the results are very close to the compilation times reported, suggesting this has nothing to do with CPU processing times or compiler/linker algorithms at all.

    Measured times as suggested above traversing the chromium directory tree:

    • Windows Home Premium 7 (8GB Ram) on NTFS: 32 seconds
    • Ubuntu 11.04 Linux (2GB Ram) on NTFS: 10 seconds
    • Ubuntu 11.04 Linux (2GB Ram) on ext4: 0.6 seconds

    For the tests I pulled the chromium sources (both under win/linux)

    git clone http://github.com/chromium/chromium.git 
    cd chromium
    git checkout remotes/origin/trunk 
    

    To measure the time I ran

    ls -lR > ../list.txt ; time ls -lR > ../list.txt # bash
    dir -Recurse > ../list.txt ; (measure-command { dir -Recurse > ../list.txt }).TotalSeconds  #Powershell
    

    I did turn off access timestamps, my virus scanner and increased the cache manager settings under windows (>2Gb RAM) - all without any noticeable improvements. Fact of the matter is, out of the box Linux performed 50x better than Windows with a quarter of the RAM.

    For anybody who wants to contend that the numbers wrong - for whatever reason - please give it a try and post your findings.

提交回复
热议问题