问题
I'm specifically asking about the old msvcrt.dll
. Hasn't Microsoft updated that library in newer versions of windows? or is that exactly the same library that one can find in Windows 98 distros?
I tested msvcrt against Cygwin with a test program that calls malloc
a lot of times by a singly linked list blocking queue with mutexes and semaphores. By ifdef
s, the program can be compiled to use Posix functions or else use Windows API calls. When compiled by MinGW with WinAPI calls the only dependency it has is kernel32.dll
, ntdll.dll
, and msvcrt.dll
, while when compiled by Cygwin with Posix functions, the program will depend on cygwin1.dll
.
I at first simply assumed that the Cygwin version will run slower because of the extra emulation layer for Posix functions; it has to translate them to WinAPI calls. But it appears that it runs 4 times faster in my machine than the MinGW compiled native binary.
The documentation of Cygwin states that it uses a different libc called newlib, and certainly the Cygwin-compiled binary does not appear to depend on msvcrt. So is this making the huge speed difference?
I have also experienced before, that when a C program calls millions of malloc
s, one that depends on msvcrt.dll
will run many times slower than any others depending on newer msvcrXX.dll
. They even ran slower than the same program running under a virtual machine linux.
What's wrong with msvcrt.dll
? Should I avoid it whenever possible?
来源:https://stackoverflow.com/questions/29954038/why-is-msvcrt-very-very-slow