none
Redirect stderr to file on network driver is very slow since VC++ 2015 / 14.0 RRS feed

  • Question

  • We experience a strange performance issue when using Visual C++ 2013 (also known as Visual C++ 12.0) compared to more recent versions like Visual C++ 2015 (also known as Visual C++ 14.0):

    The same C code is much slower when writing to stderr and redirecting this stream to a file on a network drive (Server is Linux Debian 8 / Samba).

    C:\tmp> myprog.exe 2>X:\devel\fgl\tests\zz

    When redirecting to a file on the local disk, or when redirecting to nul, the execution is fast.

    We have also tested with VC++ 2017 / 15.0, same problem.

    The reason seams to be the /MD option (link with MSVCRT.LIB), I could reproduce with a simple program:

    #include <stdio.h>
    int main(int argc, char **argv)
    {
        int n;
        system("echo %TIME%");
        for (n=0; n<200; n++) {
            fprintf(stderr,"aaaaaaaaaaaaaaaaaaaaaaaaaaaa %d\n", n);
        }
        system("echo %TIME%");
        return 0;
    }

    Then compile with and without /MD option:

    C:\tmp>cl /O1 myprog.c
    Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25507.1 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    myprog.c
    Microsoft (R) Incremental Linker Version 14.11.25507.1
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    /out:myprog.exe
    myprog.obj
    
    C:\tmp>myprog.exe 2>X:\devel\fgl\tests\zz
     9:32:27.96
     9:32:27.97
    
    C:\tmp>cl /O1 /MD myprog.c
    Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25507.1 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    myprog.c
    Microsoft (R) Incremental Linker Version 14.11.25507.1
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    /out:myprog.exe
    myprog.obj
    
    C:\tmp>myprog.exe 2>X:\devel\fgl\tests\zz
     9:32:37.15
     9:32:40.12
    
    C:\tmp>myprog.exe 2>c:\tmp\zz
     9:32:47.15
     9:32:47.20

    Is there any known issue related to stderr / network drives with VC++?

    Notes:

    • No problem when writing to stdout
    • No problem when using /MDd option (MSVCRTD.lib)
    • No problem with Visual C++ 2013 (Visual C++ 12.0, cl version 18.00.40629)


    Sebastien FLAESCH Four Js Development Tools

    Friday, June 22, 2018 7:08 AM

All replies

  • I think I answered your question on stackoverflow:

    https://stackoverflow.com/questions/50932371/redirect-stderr-to-file-on-network-driver-is-very-slow-since-vc-2015-14-0

    Sunday, November 4, 2018 5:15 PM