Jump to content
  • Advertisement
Sign in to follow this  
Raptisoft

Debug vs. Release, on Windows

This topic is 2532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is the debug .lib supposed to be so much smaller than the release .lib? Or has something gotten switched somewhere?

I am running into a strange situation... I am using the following code:


int aTick=gAppPtr->Tick();

gEngine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
asIScriptModule *aModule=gEngine->GetModule("TESTMODULE", asGM_ALWAYS_CREATE);
aModule->AddScriptSection("TESTSECTION",aBuffer.mData,aBuffer.mDataLen);
int aResult=aModule->Build();
asIScriptFunction *aFunction=aModule->GetFunctionByDecl("int GetNumber()");
asIScriptContext *aContext = gEngine->CreateContext();
aContext->Prepare(aFunction);
aResult=aContext->Execute();
if (aResult==asEXECUTION_FINISHED)
{
int aResult=aContext->GetReturnDWord();
printf("Result: %d",aResult);
}

printf("Execution Time: %d",(gAppPtr->Tick()-aTick));


To quickly and simply run this script (I was just doing a timing/syntax test):


[int GetNumber()
{
return GetOtherNumber()*2;
}

int GetOtherNumber()
{
int aResult=0;
for (int aCount=0;aCount<2000000;aCount++)
{
aResult+=2;
aResult-=1;
}
return aResult;
}


And with the release .lib, it takes about 45-50ms, but with the debug.lib, it takes only 30-35ms... that's right, the debug runs about a third faster than the release.

Angelscript.lib is almost 6mb, and the angelscriptd.lib is about 3.5.

That's not correct, right? These are reversed somehow, no? I looked at the projects, and they all look okay, but I can't believe this isn't backwards unless someone explicitely tells me so.

Share this post


Link to post
Share on other sites
Advertisement
Which project files are you using? It is indeed very strange that the release mode is slower than the debug version.

Share this post


Link to post
Share on other sites
I used the MSVC10 project, used .lib files out of the box from the download-- only thing I switched was to use multi-threaded instead of multi-threaded DLL, so that it matched my projects.

Is the size right? If that's right, then I'll assume the slowdown is coming from my project settings somehow. If I execute the script 100 times, then it's slightly faster in release mode, so could this just be one of those things?

Share this post


Link to post
Share on other sites
I use MSVC9 myself, and for me the debug version is about 5 times slower than the release version in my tests.

The size of the library in release mode is probably because of the option Enable link-time code generation (/GL). With this option the library will include a lot more information in order to allow inlining and other types of final optimizations. Turning off this makes the library about 6 times smaller on MSVC9.

It is quite possible the compilation flags in the library for MSVC10 are not properly configured for the best possible optimizations.

Share this post


Link to post
Share on other sites
Turning off /GL fixed both problems. Maybe MSVC10 has a bug? It lists /GL as "whole program optimization" so maybe it's optimizing so hard, it ends up unoptimizing, like a politician.

Share this post


Link to post
Share on other sites
It's possible. Some optimizations are theoretically good but in practice end up being slower, for example function inlining or rolling ou loops. While in you'd optimize a few instructions the code is larger and may end up getting more cache misses.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!