Skip to main content
GameDev.net gamedev.net
🔒 Locked

Optimize through VC++ .NET?

Started by xsirxx Dec 21, 2004 at 10:10 PM 37 replies 2.5k views
Original Post
xsirxx
xsirxx
I just recently switch to .NET and my code ran under the optimize options at around 640-680fps. Now it runs at 63fps. Thats around 600fps different since i switched from VC++ to .NET. Im gettin hit HARD, any ideas how to optimize that compiler to do something usefull? Thanks much. Brad
--X
wyrzy
wyrzy
.NET uses Managed Code, so the Garbage Collector could decide to run whenever it wants unless you specifically tell it when to do so. Have you specified that you want complete control over the Garbage Collector? I know there's a way to do this, but I can't think of it off the top of my head. I think its the System.GC class provides methods that control the system garbage collector, and you should be able to find it out on MSDN.

If I were programming a game in .NET, I would tell the garbage collector to run between levels, when the user saves, or whatever is a time where a few hundred milliseconds isn't going to matter.
xsirxx
xsirxx
No I dont want any managed code in this. I am doing all the memory management myself. I wanted to write for shader 3.0 support so I upped to .NET. Any ideas?

EDIT: Managed was disabled by default. So still is... and is still slow :(.

[Edited by - xsirxx on December 21, 2004 11:33:59 PM]
--X
xsirxx
xsirxx
Shameless *bump*. Any1 had problems switching to .NET and having their fps get hit this hard? any1? any1? bueler? bueler?
--X
Extrarius
Extrarius
Are you doing a release build? You say you were using VC before but don't mention a version number. Do you mean you were using VC6 and are now using VC.Net? Which version of .Net? Perhaps you dont have the optimizing compiler. If that is the case, you need to download the .Net 2003 toolkit and set your IDE to search that folder for binaries first so it will use the better compiler.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Woodchuck
Woodchuck
Hey, i will try to help you, you give me a very good idea in my similar post...

DO you scan your code checking where the time is consumed ? Like you said maybe some std things works slow now on VC++ .net. Eliminate it and all we be normal with luck :)
xsirxx
xsirxx
Im using the latest build of .NET yea, and before VC++ 6.0. I dont know which compiler I am using, I do know that under my release build settings Ive changed almost all of the settings to the optimal that are offered. This is from the MSDN page explaining each setting in depth. Ive also gone through every single setting numerous times to flick each one up and down incase a "certain" case had appeared.

As for the std vectors, yea Ive profiled it and that is where my time is being consumed the most. Thats why with VC++ 6.0 I went ahead and did the optimizing under the release build and it picked up speed to the 680fps instead of the 63fps before hand.

--Can you explain the IDE a little more? Where would that optimized compiler be? and where should I grab it if indeed thats the case?

Thanks for the replys, helps me get a bit closer to the problem.

Brad
--X
IndyJones
IndyJones
Hm - are you sure you have v-sync turned off in your app?
Also - if you are using DirectX - check for any output from the debug versions of the DirectX libraries and try switching to the release versions to see if performance gets better.

Hope that helps a bit!
xsirxx
xsirxx
Quote:
Original post by BRooksWackerman
Hm - are you sure you have v-sync turned off in your app?
Also - if you are using DirectX - check for any output from the debug versions of the DirectX libraries and try switching to the release versions to see if performance gets better.

Hope that helps a bit!


Yea Ive already switched to retail, turned off debug in all areas of DX and no difference there. Like I said the fps only changes between release and debug.
--X
xsirxx
xsirxx
Let me make this a little more simple of a question, is any1 using std::vector with .NET unmanaged code in c++? if so, how much of a slow down do you see? and difference from debug to releaase? and if release is much faster can you post all of your settings? heh thanks
--X
WilyCoder
WilyCoder
My particle engine uses std::vector to hold the particles (max of 1000).

While drawing all 1000 particles on the screen (and each particle is a 32 vertice mesh) I get around 160fps. The application is windowed.

When no particles are being drawn, I max at 833.33 fps..... :/

Radeon 9800 Pro , P4 2.6 w/ HT

CPU usage is around ~50% while the program runs.

All the code is unmanaged C++.
xsirxx
xsirxx
Did you change any settings in .NET? did you convert the program from visual 6? I am doing alot of verts a well, but the same amount from visual 6 gave me over 600fps, and now in crappy .NET I get 63 fps. You couldnt post your settings could ya? hah thats alot...

Im finding out fast that .NET is not for game programmers. Any1 have a good site that tells ya how to use shader 3.0 with the old visual?
--X
Extrarius
Extrarius
You know if you have the optimizing compiler by looking at which version of the product you bought. If you have Visual Studio Professional(or Academic or any of the better versions that include all languages), you have the better compiler. If you have just one language (VB, VC, etc), you have the worse compiler. To rectify the problem, you need to find the 'Visual C++ Toolkit 2003' on the microsoft website and then modify your global settings inside visual studio so that in the directory lists, the 'Visual C++ Toolkit 2003' directories are above the default directories.
Edit: Other thread had the link: Visual C++ Toolkit 2003
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
_the_phantom_
_the_phantom_
Quote:
Original post by xsirxx
Im finding out fast that .NET is not for game programmers. Any1 have a good site that tells ya how to use shader 3.0 with the old visual?


VS.Net is perfect for game programmers, if you do the steps outlined above to get a half decent compiler with it. The decent compiler is much more standard compliant and a much better optermiser than the VC6 compiler ever was.
WilyCoder
WilyCoder
^^ Agreed.

I did not convert my project from VC6.

Try creating a NEW project, and then adding all the files into the project.
xsirxx
xsirxx
I have 2K3 with the optimizing compiler. I have all options for optimizing able to be selected. I looked into using the toolkit, but I already had it. I also dloaded the intel compiler, that runs fine, but gives me 20 fps instead of 63 which .NET gives me. I think I have to revert back to the old compiler if I cant figure this out, thats why Im at ends. Tommorow Ill try to create a NEW project and import the files.... Dont know why that would be it, but who knows. Any ideas?

I wouldnt be so upset if I hadnt tried everything I thought I could. That and I had 600fps and cant deal with 63. YET it seems no1 else has had this problem. So Im stuck I suspose? Maybe there is a bug in that converting, Ill check that.
--X
ajas95
ajas95
Get a profiler. Then you don't have to waste time guessing. AMD's CodeAnalyst and the DevPartner Community Edition are both free fan favorites.
Leffe
Leffe
Diff the old vector implementation to the new one and figure out what affects the performance.
xsirxx
xsirxx
anon, no code changes except updating to dx9, but that wasnt much besides some null params added because of unused crap. AND yea all the settings are in release Ive gone through all the msdn docs on it...

Ive profiled in .NET and the slow down is in std::vector takes up 97% of the time. Profiled in release mode on VC6 and vector takes up about .000000000001% of the time. Its there.

As far as the diff goes, There seems to be no problem for all these other ppl, although I checked the file and instead of being 19k its 45k. So there is an obvious difference there, just dont know what it is. YET again no1 else is having this problem it seems.

Im going to rebuild today, so Ill post back in a bit with the outcome.
--X
wyrzy
wyrzy
Can you give us your compiler options for release mode?

I'm using:
/O2 /Op /Ot /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /EHsc /MD /FAs /Fa"Release/" /Fo"Release/" /Fd"Release/vc70.pdb" /W4 /nologo /c /Wp64 /Zi /TP /wd4311

I did a test using the std::vector class, and when used properly, I found it to be just as fast if not faster than standard arrays. I also upgraded my unmanaged project from VC6 to VC7.1 (.NET) recently. I got a increase of about 10-20fps after turning on all the compiler options.

What profiler are you using? I the Compuware DevPartner free edition, and its good enough for my needs.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.