Sign in to follow this  

AngelScript 1.9.1 WIP 2 (2004/09/14)

This topic is 4838 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

After finding out that Lua was about 2 times as fast as AngelScript I started thinking more about how to improve the performance. I already implemented the easiest optimizations which has improved the performance with about 30-50%. I have plenty of ideas for other changes that might improve the performance even more, and I'm certain that I will be able to make AS at least as fast as Lua. AngelScript has the advantage of being strongly typed and the ability to call C/C++ functions directly without wrapper functions. The ultimate optimization would be to compile directly to machine-code, but that is a step I'm not ready to take yet. That part will probably be done through a plug-in-able JIT compiler or something like that. I'm planning on making these optimizations gradually over time, as I would otherwise have to stop further development of the library features, which is not something that I want to do. Here are the changes for the latest WIP: - bug fix: Switch-case didn't work correctly if the cases were not ordered in ascending order (thanks Dmitry "RCL" Rekman) - bug fix: The ternary operator ?: didn't release temporary variables as it should, causing an assert failure in the debug version (thanks Dmitry "RCL" Rekman) - bug fix: Passing string constants to condition operator would cause an assertion failure. (thanks Joe "Desdemona" Wright) - Added support for asCALL_CDECL_OBJFIRST (thanks Tristan "Kurioes" Hartskeerl) - Improved performance of byte code execution with about 30% Regards, Andreas Jönsson Author of AngelScript [Edited by - WitchLord on September 14, 2004 7:44:05 PM]

Share this post


Link to post
Share on other sites
Hi,

I tried 1.9.1-WIP1 and I am pretty glad with the results. Performance gain is not just 30%-50% as you state. Right now the results are:

Lua: 20.499574 sec
AngelScript: 23.772902 sec

So it is nearly the same!!

I dunno why there is such a great performance boost. Older version performed nearly 2 times slower.

By the way, I did a mistake and AS version of performance test was not 100% identical to Lua version (there is one 'multiply' operation more each iteration, and the loop is one iteration less than Lua version). For tests to be identical, '*=' should be replaced with '=' in func3() for AS version and condition in 'for' loop should be changed from '<' to '<=' to match Lua's 'for'. I thought that could be the reason affecting performance, but even with the 100% identical tests, older version performs nearly 2 times as slow as Lua:

(Results for 1.9.0, 'tweaked' by me (ExecuteNext() rearranged, bcSize[] changed to enumerants), identical script )

Lua: 20.489861 sec
AngelScript: 36.730612 sec

Great work!

Cheers,
RCL

Share this post


Link to post
Share on other sites
Well, that is certainly great news. [smile] Already almost as fast as Lua, and I haven't even applied all the optimizations that I thought of. That was just the most simplest of them.

I don't know either why you get such an incredible performance improvement. When I measured the performance difference between 1.9.0 and 1.9.1 WIP1 it was only about 30%-50% faster. Could it be that you changed the compiler flags?

Wait a minute...

It's all about calculations:

1 - (23.77 / 36.73) = 0.35 (35% performance increase)

36.73 / 23.77 = 1.55 (1.9.0 is 54% slower than 1.9.1WIP1, or 65% as fast as 1.9.1WIP1)

23.77 / 20.50 = 1.16 (AS1.9.1WIP1 is 16% slower than Lua, or 86% as fast as Lua)

I'm not sure if the meaning of these calculations are actually what I think but I believe they are.

Share this post


Link to post
Share on other sites
I've just uploaded the second WIP. The changes are:

  • String constants are now concatenated by the compiler if they are only separated with whitespace or comments, i.e. "Hello " "Andreas" becomes "Hello Andreas"
  • asCALL_CDECL_OBJFIRST should now work, which allows application to register global functions as object methods where the first parameter is the object pointer
  • The ?: operator has been corrected once more due to bug reports that I received from Joe Wright


No optimizations were made in this update.


Share this post


Link to post
Share on other sites

This topic is 4838 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this