Debug vs. Release, on Windows

Started by
4 comments, last by WitchLord 12 years, 3 months ago
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.
Advertisement
Which project files are you using? It is indeed very strange that the release mode is slower than the debug version.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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?
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement