Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-compile scripts? #865

Open
VinnyVicious opened this issue Apr 26, 2024 · 6 comments
Open

Pre-compile scripts? #865

VinnyVicious opened this issue Apr 26, 2024 · 6 comments

Comments

@VinnyVicious
Copy link

Would it be possible to pre-compile rhai scripts used in an application and bundle them with the application? The reason I ask is due to the fact that performance is not great (compared to our current implementation with C++ and LuaJIT), but there are clear advantages in our project by moving to Rust/Rhai. If pre-compiling was a possibility, then I'm sure speed would be much better.

@schungx
Copy link
Collaborator

schungx commented Apr 26, 2024

That would require serializing the AST into some format (perhaps binary). However, based on my previous benchmarks, it doesn't seem to be faster deserializing an AST vs just compiling the script again. In fact, compiling a script into AST appears to be faster than deserializing a pre-generated AST from binary format.

If scripts compilation need only be done once, I wonder what would be the problem with your performance issues?

@schungx
Copy link
Collaborator

schungx commented Apr 26, 2024

In fact, you can use Rust with LuaJIT and then retain all your existing scripts. There are Rust bindings for LuaJIT, I believe.

Why not go that route?

@VinnyVicious
Copy link
Author

Rhai allows me to easily build to tons of platforms, including musl. LuaJIT is kind of prohibitive. :(

@schungx
Copy link
Collaborator

schungx commented Apr 26, 2024

Rhai allows me to easily build to tons of platforms, including musl. LuaJIT is kind of prohibitive. :(

OK... that makes sense.

So what aspects of Rhai do you find slower than you wish?

@VinnyVicious
Copy link
Author

Haven't got that deep down yet, it was a very native comparison between separate builds doing the same game logic. Once I have useful and actionable information, I'll share it for sure.

Thanks for creating rhai! :)

@schungx
Copy link
Collaborator

schungx commented Apr 26, 2024

Thanks for creating rhai! :)

Well I didn't create Rhai... it was originally created by JT. I merely picked up maintenance of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants