BlindMindStudios JIT-Compiler and AS 2.3

Started by
24 comments, last by Sir Ementaler 8 years ago

The JIT by BlindMinStudios is almost the official JIT for Angelscript, since it is the only one, and it works really well :-). Since it is open source, I guess it is mainly a matter of getting more people involved in its maintenance. I have tried to get into it and was able to find a few problems some time ago, but fixing and enhancing the JIT is another story. Maybe a short tutorial for beginners would help?

I am glad to hear that updates are likely to happen down the road! @GGLucas: feel free to ask on the forum or GitHub if you need any help - I'd be glad to spend time on it.

The dynamic modules API sounds great. I have been thinking about doing something similar but was waiting for the new APIs to avoid deprecation issues - but now I am kind of stuck with 2.29 because of the dependency on the JIT. I have also looked at integrating libffi at some point to dynamically load native libraries from Angelscript. Again, feel free to share with the community :-)

Advertisement

GGLucas - Thanks for the head's up! Cannot wait! Had a bad feeling the project just died.

Would you have any examples to back that up? Not that I doubt you, but I would very much like to see what performance bottlenecks people are experiencing so I can look into them, and make improvements.

Objectively I have only seen benchmarks by others and some of them are old (like this). I personally haven't tried making an apple to apple comparison as that would involve writing equal functions in several scripting languages. And I don't want to write them in Lua or something similar, because I hate it's syntax (that is the reason why I'm here happily using AS biggrin.png). But I guess I will try to do some benchmarks with some languages if that can improve AS performance down the line.

But I did test JIT compilation about a year back and I must say I saw a great increase in speed. A simple loop in AS is about 10x slower than native O3 C++, but only about 3x slower in JIT (I did a loop with 20k iterations calling a C++ function in each one). I don't know about optimizations AS compiler does for things like loops, but maybe even loop unrolling could be of benefit.

I have looked into GCCJIT and similar (i.e. Clang related) projects as well that allows JIT compiling using already mature compilation frameworks. So if we had AS JIT just an implementation using gccjit then optimization wise a lot of things would get simpler. Sadly none of those JIT compilers are complete and are only partly maintained. So while it is worth checking out, I don't think it's worth investing now.

I cannot argue against that. I'm certain it would be beneficial, the only problem with that is a time constraint I have. I really cannot assume more work. I only work on AngelScript on my spare time, and between my family and job this time is quite limited. I have to chose well what I can do on what little time I do have. I'm already only able to work on a small fraction of all the ideas I have for AngelScript as it is.

The amount of contributors is sadly not large either. I am in a project like that now too, where it is actually very promising and I will personally use it till I die, but it is hard to get others who are competent enough to help and willing enough to do so. As I use AS more and more and I am hoping to help later on with development too. But then you will have to switch to Git. tongue.png I honestly think that would also help with getting more contributors.

It would be a whole different matter if I could somehow make a living working on AngelScript, but that is not the case.

Sadly all I can do is donate the money I can spare. Maybe a bit more popularity to AS is required, before more people start using it. AS is quite old already, but for some reason it didn't catch on as some other languages did.

The dynamic modules API sounds great. I have been thinking about doing something similar but was waiting for the new APIs to avoid deprecation issues - but now I am kind of stuck with 2.29 because of the dependency on the JIT. I have also looked at integrating libffi at some point to dynamically load native libraries from Angelscript. Again, feel free to share with the community :-)

This is also something I have been pondering about, because I want AS to be used as an extension system as well, not just a scripting language. So I am thinking on how to allow loading and calling dynamic libraries (like dll's on windows) purely from AS. Has anyone tried it? In C++ I would need to use GetProcAddress which involves pointers which we cannot have in AS. In C# it is easier, but doesn't apply here. So is a there a way to load a .dll and call a function from it purely via script?

GGLucas - Thanks for the head's up! Cannot wait! Had a bad feeling the project just died.

Would you have any examples to back that up? Not that I doubt you, but I would very much like to see what performance bottlenecks people are experiencing so I can look into them, and make improvements.

Objectively I have only seen benchmarks by others and some of them are old (like this). I personally haven't tried making an apple to apple comparison as that would involve writing equal functions in several scripting languages. And I don't want to write them in Lua or something similar, because I hate it's syntax (that is the reason why I'm here happily using AS biggrin.png). But I guess I will try to do some.

So when I did my research on angle script I choice it for the following reasons:

The sytax - it looks just like c++ it basically is a c++ redirect which makes it a very nice scripting language

The simplicity - backend via the class and function interface is very clean, well written descriptive functions and classes that make sense and are easy to use

The documentation - It is very well documented compared to almost every other scripting language out there. Almost every document, class, function etc is not only defined but also there are clear easy to read description.

The examples - there are very well through out simple to follow and expand, examples which make integration easy and simple.

Though I'm not discounting your research on the topic but your topic post was written almost 3 years ago, and provides little to no detail about what kinda code he used. From my understanding, path finding is probably not the best bench mark test, manly due to the fact that angel scipt has not back end memory management system. His code probably was fairly inefficient due to his lack of knowledge of the scripting language. I have been looking around for good bench marks and there really arent many, the most recent one http://urho3d.prophpbb.com/topic454.html?sid=2d7499b0a5a00f5aaa2586b5016e7a61#p2506. This is still fairly old, and due to various compatibility modes that angel script has, this may improve or hurt the final results. It would be nice to see a few standard bench mark test examples, in future releases. There seems to be a lot of bad/miss information about the scripting language/engine, because so little people have spent the time to look at it thoroughly.

chasester

Benchmarks for comparing two languages are extremely hard (if not impossible) to make truly fair. One language might do better in one situation, while the other language does better in another situation. Who's to say which situation will actually occur more frequently in most real world applications?

If you read Upvoid's article carefully you'll note that they admit that AngelScript is faster than Lua, when not using LuaJIT. For some reason they had trouble getting BlindMind's JIT compiler to work at the time so they ended up comparing AngelScript without JIT against other languages with JIT. Considering that, I think it is pretty amazing that AngelScript ended up being only 3 times slower than the other languages (not counting C++). biggrin.png

JIT is always going to boost the performance of any VM, since it is translating the bytecode that the VM has to interpret into native code that the CPU can execute directly. That's why when using JIT you usually see a 3 to 10 times boost in performance.

One thing about JIT that you need to keep in mind is that not all platforms allow this to be used. For example, on Apple's iOS it is strictly forbidden. I'm not too sure about Android, but it is likely also not allowed due to security reasons.

Anyway, I love a challenge, so if you show me a situation where AngelScript has a particularly bad performance I'll definitely do whatever I can to improve it. tongue.png

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 is also something I have been pondering about, because I want AS to be used as an extension system as well, not just a scripting language. So I am thinking on how to allow loading and calling dynamic libraries (like dll's on windows) purely from AS. Has anyone tried it? In C++ I would need to use GetProcAddress which involves pointers which we cannot have in AS. In C# it is easier, but doesn't apply here. So is a there a way to load a .dll and call a function from it purely via script?

You could quite easily implement and register a C++ function that would load the dll, call GetProcAddress to get the address of the desired function and register it with the AngelScript engine, and then return the asIScriptFunction pointer to the script in a generic handle. The script can then cast the handle to the desired funcdef in order to call it. The most difficult part would be to determine/verify that the correct signature is used to register the function, because unless you use something like IDL you don't really know the signature of the function you get from the dll and you'll have to trust the script to pass the correct signature.

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've pushed an update to the JIT repository for compatibility with the newly released 2.31.0 version.

If anyone notices any remaining issues that I missed, feel free to post or open an issue on github.

You guys rock! Thanks for the time you've invested into this. I'll have to consider purchasing a game from you guys to express my gratitude.

Thanks again.

Thank you! Can't wait to test it out!

Awesome, thanks! Will check it out asap!

Just wanted to report that AS 2.31 and the latest version of the JIT work very well. I haven't run performance tests yet to check if array access is faster thanks to the new instruction.

Thanks again!

This topic is closed to new replies.

Advertisement