Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Debug vs. Release, on Windows


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Raptisoft   Members   -  Reputation: 171

Like
0Likes
Like

Posted 08 January 2012 - 06:28 PM

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.

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3261

Like
0Likes
Like

Posted 08 January 2012 - 07:21 PM

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

#3 Raptisoft   Members   -  Reputation: 171

Like
0Likes
Like

Posted 08 January 2012 - 07:30 PM

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?

#4 Andreas Jonsson   Moderators   -  Reputation: 3261

Like
0Likes
Like

Posted 08 January 2012 - 07:57 PM

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

#5 Raptisoft   Members   -  Reputation: 171

Like
0Likes
Like

Posted 09 January 2012 - 05:14 AM

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.

#6 Andreas Jonsson   Moderators   -  Reputation: 3261

Like
0Likes
Like

Posted 09 January 2012 - 04:56 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS