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

Some comments re Rhai packages #2

Closed
schungx opened this issue Jun 17, 2020 · 6 comments
Closed

Some comments re Rhai packages #2

schungx opened this issue Jun 17, 2020 · 6 comments

Comments

@schungx
Copy link

schungx commented Jun 17, 2020

https://github.com/alvinhochun/wasm-project-template/blob/rhai-demo/wasm-module/src/scripting.rs#L10-11

You don't need these lines:

engine.load_package(ArithmeticPackage::new().get());
engine.load_package(LogicPackage::new().get());

Engine::new() already includes these packages. You don't have to load them once again and it'll be better on speed.

If you want to only include these packages and nothing else, you should use Engine::new_raw(). This way, the WASM size will be significantly reduced because code from non-loaded packages will not be included.

@schungx schungx changed the title Some comments Some comments re Rhai packages Jun 17, 2020
@schungx
Copy link
Author

schungx commented Jun 17, 2020

Not sure if these in Cargo.toml will reduce the WASM size:

lto = "fat"
codegen-units = 1

alvinhochun added a commit that referenced this issue Jun 17, 2020
@alvinhochun
Copy link
Owner

Fat LTO does cut down about 12KB in raw size, but it is currently a bit broken on Rust stable.

@schungx
Copy link
Author

schungx commented Jun 17, 2020

Well, how about lto = true?

@alvinhochun
Copy link
Owner

Same thing.

@schungx
Copy link
Author

schungx commented Jun 17, 2020

I've been using LTO for quite a while now (well, actually months), and it has been stable so far...

Really needed this for dead-code removal... without it the binaries tend to be huge.

@alvinhochun
Copy link
Owner

I've been using LTO for quite a while now (well, actually months), and it has been stable so far...

No, it's an issue specific to Wasm: rust-lang/rust#72758

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