Skip to main content
gamedev.net
🔒 Locked

Squirrel2 is slow for me

Started by JD 8 replies 2.7k views
Original Post
JD
JD
Anyone else seeing 200x speed hit over C/C++ ? Is this normal?
Kylotan
Kylotan
I'm sure it depends on what you're trying to do.
JD
JD
This script is 40x slower than C++ version:

-------------------
function foo()
{
for(local i = 0; i < 10; i++)
bar();
}

function bar(){local b=0; b++;}

foo();
--------------------

The more iterations the slower it gets. I assume I would be doing at least 10 function calls in my scripts. Profiling the following yields 38x slowdown:

-----------------------
function foo()
{
local a = 0;
a++;
}

foo();
-------------------

That's just one call, no iterations at all. Everything is benched in release mode and the timer works fine.

Really interesting that a simple function call (no params) and a iteration is so much slower. Is this normal in other scripting langs?
JD
JD
That might be happening, I haven't checked the asm output. Still, function call takes 40x hit? I'm checking out angelscript to see what it's like.
JD
JD
Ok, angelscript is only 3x slower than my C++ code whereas squirrel is like 25x slower than my C++ code. Both scripting langs. are compared to same C++ test code ie. the foo/bar combo above. AS is setup per default other than it's in a lib like squirrel and everything is run in release mode.
fagiano
fagiano
I'm actually working on performances this very moment :)
Squirrel 2.0 so far as been a step back in terms of performance compared to 1.0, because I was focusing on the new laguage features. I'm actually going to release 2.0.2 in few days(as soon as it passes all tests).
I made some small change that improved performance a lot, expecially on function calls(and expecially if you use GCC). Plus it compiles with exception handling turned off that gains some additional cycle.

I use squirrel in production since a while and so far is definitevely not my bottleneck it barely appears in the profiler.

About angel script I can't say, but seems to me that is a whole other universe to make a comparsion.

I usually use lua as template and according to my last tests squirrel is 30% slower on function calls but 20% faster when you deal with arrays etc...
(talking about the unreleased 2.0.2. The current version is slower).
On large datasets well, squirrel gains ground proportionally to the size.
Considering that lately squirrel packs a lot more fetures I'm very satisfied by its performances.

If you send me more infos on what you are trying to do, I'll be glad to work it.


ciao
Alberto


-----------------------------The programming language Squirrelhttp://www.squirrel-lang.org
JD
JD
Ahh, that explains it. I do like the squirrel features especially the concept of class properties that marry it to the world editor. I'm still playing with the whole idea of using a scripting lang. in my tools so the first thing on my mind was to profile some scripting langs. to see what the speed hit was like. Granted, it all depends on how frequently engine calls scripts and how complex the scripts are. Whether they call C functions or native script functions. I do want to be flexible and want the player to define the game his way as much as possible. Have you run into a situation with FarCry where you had to resort to C functions because the scripts were slow? Can you tell me what was the breakup in speed ie. renderer took 40% of total time, scripts took 20%, basically something like that. This would give me an idea where the bottlenecks are and let me decide whether I should be using a scripting lang or C dlls. My technology is similar to FarCry/Doom3 ie. first person shooter action game, no network stuff right now. Thanks.
fagiano
fagiano
Take a look at this post, I talk about FarCry+LUA pro and cons and explain what I aim to solve with squirrel(at the time 1.x).

http://www.gamedev.net/community/forums/topic.asp?topic_id=230021&PageSize=25&WhichPage=1

my current system uses squirrel but the basic concepts behind are similar(entities wise) except that I use classes that save quite a bit of mem.

Plus now I have also the main loop and level loading in squirrel.

ciao
Alberto
-----------------------------The programming language Squirrelhttp://www.squirrel-lang.org
JD
JD
Ok, I'll think about this some more. Thanks for your help.

Topic Locked

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

Sign in to reply to this topic.