473,721 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VC6 speed vs VS2003

YAZ
Hello,
I have a dll which do some number crunching. Performances (execution
speed) are very important in my application. I use VC6 to compile the
DLL.
A friend of mine told me that in Visual studio 2003 .net optimization
were enhanced and that i must gain in performance if I switch to VS
2003 or intel compiler. So I send him the project and he returned a
compiled DLL with VS 2003.
Result : the VS 2003 compiled Dll is slower than the VC6 one. For
example the creation of a matrix of 2000000 double random values last
230 ms in the VC6 DLL and 330 ms in the VS 2003.
Then he compiled the project with intel C++ compiler 9.0 inside VS 2003
with maximum optimization /fast flag and the result is 300 ms.

At last he tried the intel C++ compiler inside VC6 and the result was
200 ms with the /O2 flag. But the DLL generates External exception when
compiled with the /fast flag in VC6.

So :
Compiler flag execution time
VC6 /O2 230 ms
VS2003 /O2 330 ms
icl+VS2003 /fast 300 ms
icl+VC6 /O2 200 ms
icl+VC6 /fast external exception

I can't believe that the compiler in VS 2003 is so bad. May be the link
library are differents ? I use libc.lib /ML in VC6.

Do you have any experience with switching from VC6 to VS2003 ?

Nov 17 '05 #1
7 3044
YAZ wrote:
Hello,
I have a dll which do some number crunching. Performances (execution
speed) are very important in my application. I use VC6 to compile the
DLL.
A friend of mine told me that in Visual studio 2003 .net optimization
were enhanced and that i must gain in performance if I switch to VS
2003 or intel compiler. So I send him the project and he returned a
compiled DLL with VS 2003.
Result : the VS 2003 compiled Dll is slower than the VC6 one. For
example the creation of a matrix of 2000000 double random values last
230 ms in the VC6 DLL and 330 ms in the VS 2003.
Then he compiled the project with intel C++ compiler 9.0 inside VS
2003 with maximum optimization /fast flag and the result is 300 ms.

At last he tried the intel C++ compiler inside VC6 and the result was
200 ms with the /O2 flag. But the DLL generates External exception
when compiled with the /fast flag in VC6.

So :
Compiler flag execution time
VC6 /O2 230 ms
VS2003 /O2 330 ms
icl+VS2003 /fast 300 ms
icl+VC6 /O2 200 ms
icl+VC6 /fast external exception

I can't believe that the compiler in VS 2003 is so bad. May be the
link library are differents ? I use libc.lib /ML in VC6.

Do you have any experience with switching from VC6 to VS2003 ?


What's the complete set of compiler and linker options that you're using,
but for VC6 and VC7.1?

In general, the VC7.1 optimizer is better, but there may be other options
that are masking that effect (and the Intel compiler will duitifully
reproduce that behavior as well, since they really try to be switch
compatible with the corresponding version of VC).

Finally, make sure you're measuring the performance of something that
matters. Creating a large number of random numbers is probably not a
scenario that you're really interested in. You may in fact be comparing the
performance of two different random number generators. If the random number
generator in VC7.1 was improved to produce better randomness, for example,
it's very likely that it would also be slower. If you really want to
measure random number generation, make sure that you're using your own
generator (not rand(), etc), so that you know you're running the same code
in both environments.

-cd
Nov 17 '05 #2
YAZ wrote:
Hello,
I have a dll which do some number crunching. Performances (execution
speed) are very important in my application. I use VC6 to compile the
DLL.
A friend of mine told me that in Visual studio 2003 .net optimization
were enhanced and that i must gain in performance if I switch to VS
2003 or intel compiler. So I send him the project and he returned a
compiled DLL with VS 2003.
Your friend is right. VS 2003 and the Intel compiler are the best
compilers available for Windows, regarding speed of generated code.

Optimization has been enhanced. Which surely doesn´t mean that your
programs are always faster. But IMHO shouldn´t be that slower ;-)
Result : the VS 2003 compiled Dll is slower than the VC6 one. For
example the creation of a matrix of 2000000 double random values last
230 ms in the VC6 DLL and 330 ms in the VS 2003.
Is that pure memory allocation and filling or are some floating point
calculations involved ?
Then he compiled the project with intel C++ compiler 9.0 inside VS 2003
with maximum optimization /fast flag and the result is 300 ms.

At last he tried the intel C++ compiler inside VC6 and the result was
200 ms with the /O2 flag. But the DLL generates External exception when
compiled with the /fast flag in VC6.
Curious. Why should the same compiler (Intel 9.0) emit different code
with the same settings in different IDE´s ? Your project settings (VC6 /
VC 2003) must be different. Or did you compile from the command line ?
[...]
Do you have any experience with switching from VC6 to VS2003 ?


I had a look at the generated code ;-) and VC7 (VS2003) optimizes much
better and generates faster code. If you use link time code generation
(global optimization and whole program optimization) the compiler can
use more cpu registers and eliminates function calls and even inlines
code called in different cpp files.

Perhaps you should have a look at the following settings (VC 2003)

a) /O1 is commonly faster

b) RTTI / Exception handling may reduce speed.

c) Security checks (/GS) may reduce (slightly) the performance
(on in release builds)

d) Runtime library (Single / Multithread) has a significant impact
on the speed of e.g. memory allocations and other runtime library
functions

e) Are you using P4 code optimizations ? Though the generated code
runs on P3 processors, it will run slower on non P4 CPU´s.

f) VC 2003 doesn´t use an optimized heap for small memory blocks
on Win2K and upper. I don´t know if this was already the case
for VC6.0. VC 2003 uses the Windows heap instead, to AFAIK prevent
heap fragmentation.
Allocating many small memory blocks might be slower in VC 2003.
It´s one of the reasons why VC 2003 is complained to generate slower
code than other compilers. Though i would recommend to rewrite
the program if the speed difference is due to memory allocation.

Though you may enable the small block memory heap with

_set_sbh_thresh old

(But i wouldn´t recommend it generally).
If your program does allocate many small memory blocks and the speed
changes significantly when you are using the function _set_sbh_thresh old
i suppose the speed difference is due to changes in the runtime library
and the heap management.

If not - then you should check the project settings. If they are the
same or if you are using the compiler from the command line i can´t
explain the speed difference and i would recommend you to use the
profiler comming with the Intel compiler to find out which part of the
program is causing the speed difference.

Hope that helps.
Andre
Nov 17 '05 #3
YAZ
He imported the dsw project that i send to him so the compiler setting
are the same.

My setting in VC6 are
/ML /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "KERNEL_EXPORTS " /FR"Release/" /Fp"Release/Kernel.pch"
/YX /Fo"Release/" /Fd"Release/" /FD /c

for the compiler and :
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib ws2_32.lib /nologo /dll /incremental:no
/pdb:"Release/Kernel.pdb" /machine:I386 /out:"Release/Kernel.dll"
/implib:"Release/Kernel.lib"

for the linker.

The setting in VS2003 are :
/O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D
"KERNEL_EXPORTS " /D "_WINDLL" /FD /ML /Fp".\Release/Kernel.pch"
/Fo".\Release/" /Fd".\Release/" /FR".\Release/" /W1 /nologo /c

and
/OUT:".\Release/Kernel.dll" /INCREMENTAL:NO /NOLOGO /DLL
/PDB:".\Release/Kernel.pdb" /IMPLIB:".\Relea se/Kernel.lib" /MACHINE:X86
odbc32.lib odbccp32.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

The setting in intel compiler are :
/c /fast /Og /Oi /Oy /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL"
/D "KERNEL_EXPORTS " /D "_WINDLL" /FD /ML /Fo".\Release/"
/FR".\Release/" /W1 /nologo /Gd /Qparallel

and
/DLL odbc32.lib odbccp32.lib ws2_32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/OUT:".\Release/Kernel.dll" /INCREMENTAL:NO /NOLOGO /TLBID:1
/IMPLIB:".\Relea se/Kernel.lib" /MACHINE:X86

Of course the difference in speed is global and not only in the random
number generation. BTW I use my own routine to make the generation of
random numbers.
Loops for example are slower . Which is strange in random number
generation is the VS2003 & intel are slower in the memory allcoation of
2000000 double and coping them to another matrix. There are based on
new operator and memcpy which proofs that the link library libc.lib in
my case is fatser in VC6.
The other functions in the library give the same performance when
applied to small matrix. But if the memory allocation and copying is
slower in VS2003 and intel c++ the whole application will be slower.
After all the application job is manipulating objects by creating,
copying and deleteing them.

Another thing is that that intel c++ inside VC6 generates External
exceptions !!! . My friend says that he have intel c++ 9.0 installed in
VS2003 but it's accessible from VC6 too. He is doubting that the intel
compiler are mixing libraries from VC6 and VS2003. When he tried /O3
instead of /fast the DLL works fine but the DLL is a slower than with
/O2 .

My impression that the whole performance difference is due to the link
libraries (libc.lib) which are better in VC6.

The last thing is that my CPU is ATHLON 64 , 2GHz, 1GRAM and my be
intel & VS2003 DLL will be faster on a P4.

Nov 17 '05 #4
YAZ wrote:
He imported the dsw project that i send to him so the compiler setting
are the same.

Ok, then both settings (VC7 and VC6) should be the same and the speed
difference should be caused by the runtime library, as i assumed in my
last post and you too.
[...]
The setting in VS2003 are :
/O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D
"KERNEL_EXPORTS " /D "_WINDLL" /FD /ML /Fp".\Release/Kernel.pch"
/Fo".\Release/" /Fd".\Release/" /FR".\Release/" /W1 /nologo /c

Everything OK.

You could add: /Og /GL. for global optimization

This might result in better code, when handling with doubles (alignment).

and

/G7 for P4 / Athlon specific optimization
(G7 won't be supported anymore in VC8).
[...]

generation is the VS2003 & intel are slower in the memory allcoation of
2000000 double and coping them to another matrix. There are based on
new operator and memcpy which proofs that the link library libc.lib in
my case is fatser in VC6.
The other functions in the library give the same performance when
applied to small matrix. But if the memory allocation and copying is
slower in VS2003 and intel c++ the whole application will be slower.
After all the application job is manipulating objects by creating,
copying and deleteing them.

You could add the following lines to your main(...) or DllMain(...).

#include <malloc.h>

const size_t UseSmallBlockHe apForMaxBytes = 256; // You may
try higher // or lower values

int _tmain(int argc, _TCHAR* argv[])
{
_set_sbh_thresh old(UseSmallBlo ckHeapForMaxByt es);

.....
}

This should boost your program's speed, if compiled with VC 2003.
But i wouldn't recommend this setting generally, because it might reduce
the speed of your programs, due to heap fragmentation.
Memory allocations are time consuming and therefore you should reduce
them by using e.g. boosts multi_arrays or special math libraries (matrix
template library etc.). This should also boost the speed of your VC6
compiled program. Especially if you are using dense / sparse matrices.
Each single memory allocation needs additional memory for internal heap
management and alignment.
Therefore most STL containers are using their own memory allocators and
are allocating only large blocks of memory from the programs heap.

[...]
My impression that the whole performance difference is due to the link
libraries (libc.lib) which are better in VC6.

Obviously at the first sight yes. But your programs will suffer from
heap fragmentation and cache failures, due to the increased memory overhead.
And if you have multiple dlls, each using a statically linked runtime
library, the overhead in using the internal and the Windows heap should
be even more significantly. This is why using a dynamic linked runtime
library results sometimes in faster programs compared to the static
linked ones.

The last thing is that my CPU is ATHLON 64 , 2GHz, 1GRAM and my be
intel & VS2003 DLL will be faster on a P4.


Don't think so. At least not (that) significantly. Normally the Athlon
should be "faster" executing single threaded programs.

Andre
Nov 17 '05 #5
YAZ
Thank you André

In fact the _set_sbh_thresh old(UseSmallBlo *ckHeapForMaxBy tes=256) call
changed completely the performance of my application. Now I have nearly
the same speed as with VC6. Some fonctions are slower and other are
faster.
The speed difference is less than of 2% in favor of VC6.
I'll try to play with the UseSmallBlo*ckH eapForMaxBytes value in order
to optimize.
Thank you all

Nov 17 '05 #6
YAZ
BTW,
I use atlas and lapack libraries in the matrix computation.
But I was surprised when you say
This is why using a dynamic linked runtime
library results sometimes in faster programs compared to the static
linked ones


Because I never got better performance with DLL run times. and less
with the multi threaded version of the run times.

Nov 17 '05 #7
YAZ wrote:
BTW,
I use atlas and lapack libraries in the matrix computation.
But I was surprised when you say
This is why using a dynamic linked runtime
library results sometimes in faster programs compared to the static
linked ones

Because I never got better performance with DLL run times. and less
with the multi threaded version of the run times.


Sorry for the late answer - back from vacation.

It depends on your application. The dynamic runtime library isn´t
generally faster than the static linked one.

But if your application uses many DLL´s which are also using the static
runtime library the memory usage will be much higher, than if all the
DLL´s would be using the dynamic runtime library. And if you have an
application using much memory the speed difference might be significant.

André

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1430
by: Arun Kumar | last post by:
Hi I am new to .NET. I have VS.NET 2003 and VS.NET 2005 Beta 2 Installed on my PC. I created a Windows Application which uses COM object. Its a simple test. When I Build the application on VS 2003 and building solution and runs faster than VS 2005. Does it mean if I switch to VS 2005 later this year when its released it going to be slower than VS 2003? Program I created was using C#.NET
6
1555
by: White Knight | last post by:
I need the new "Port" functionality of Net Framework 2 to complete a project that is being produced using VS2003 and C#. If I download the release version will this cause problems with VS2003, and my earlier C# projects?
7
1648
by: tonelab | last post by:
I currently have VS2003 .net 1.1 installed with a number of 1.1 projects built in it. All of these projects create the /bin dll for deployment and have been running on remote servers that have the 1.1 framework installed. If I install Visual Web Developer Express Edition 2005 on my machine, it will install the .net 2.0 framework. When I go back and open up the 1.1 projects in VS2003 and deploy them again creating the /bin dll, will they...
3
1796
by: Darrin | last post by:
Hello, I see that VS2005 and the new framework 2.0 is out to the public now. Wondering about some things. When you install the new framework 2.0 can a person still use visual studio 2003 or do you need to use Visual Studio 2005? If you can use the new framework 2.0 with VS2003 are there any benifits?
7
1711
by: Frank Rizzo | last post by:
Is it me or is the speed of VS2005 actually slower than VS2003? The startup is pretty bad - even though I changed VS to display an empty environment. When I create a new form and want to change its size: while I am resizing, an hour glass comes up for a few seconds. There a lot of other slowdowns all over the system. It seems like it the hard drive kicks in really hard. Now I did have the VS2005 beta installed, but I uninstalled it...
5
1507
by: Dariusz Tomon | last post by:
Hi I noticed that all my ASPNET applications (+ MSSQL Server - I checked the database and it is ok) run very slowly (especially from the beginning). I made comparison to other applications (not mine) on another servers. I wonder how could I boost the applications. The only thing I suspect is that in configuration manager in my VS2003 I have got debug. Could you tell me your suggestions please?
15
4224
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers mapped to the local devleopment folder. Project compiles to a subfolder .\bin. To deploy, the asmx page and bin subfolder are copied to the production server. So now I upgrade to VS2005. OK, so except for the name, everything is changed. No more...
5
2224
by: Tony | last post by:
Hi all, Here's the link to the issue we were seeing on our ASP.NET system when modifying, adding and deleting directories in framework 2.0. http://blogs.msdn.com/toddca/archive/2005/12/01/499144.aspx I then tried a few of solution I found while perusing Google, - FCNMode registry mod - Relocating to App_Data folder to create/modify/delete directories.
3
3591
by: Chris288 | last post by:
Hi, I have a problem where our app when compiled in VS2005 runs about 50% the speed it attains in VS2003. This is an unmanaged C++ app. I have tried most combinations of the optimization and language settings with little change in run speed. I compared the generated native code in various places in the code and noticed two things.
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.