Okay, updated them and compiled with opt-level=3, and wee_alloc on. Compilation took a really long time, but I get that it's a prod feature, not a dev feature. Wasm file was 1.3Mb, though :/
I tried compiling with s and z to see the file size difference, but it failed to compile when I tried that (it deleted the pkg directory and then didn't regenerate it)
$ rustc --version
rustc 1.37.0-nightly (088b98730 2019-07-03)
$ cat Cargo.toml | sed -n '/profile.dev/,/default/p'
[profile.dev]
lto = true
opt-level = 3
[features]
# If you uncomment this line, it will enable `wee_alloc`:
default = ["wee_alloc"]
$ du -h pkg/index_bg.wasm
1.3M pkg/index_bg.wasm
# durations:
# rust: between 1 and 3.5 ms (usually between 1 and 2)
# js: between 2.5 and 3.5ms
Oh, that's probably what I did wrong, I just had opt-level=s, not opt-level="s"
The error wasn't interesting, it was about how it tried to import the index, but the file wasn't there. I'm 90% sure it originated in the browser and that the server was just echoing it for me to see. Other than that, it just said "build failed". Which is interesting, because when I set it to opt-level=5, it told me that the only valid values were 1-3, and s and z, so it's a bit surprising that I didn't get that error again).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hold up, I'm going to update my rust and add the optimizations and see what sizes and times we get.
Okay, updated them and compiled with opt-level=3, and wee_alloc on. Compilation took a really long time, but I get that it's a prod feature, not a dev feature. Wasm file was 1.3Mb, though :/
I tried compiling with
s
andz
to see the file size difference, but it failed to compile when I tried that (it deleted thepkg
directory and then didn't regenerate it)Anyway, good article, thanks for writing it up :)
What was the error message when you did
s
andz
? You should pass it as a String.All the above tests are run on rustc
1.37.0-nightly (929b48ec9 2019-06-21)
WASM file size is around that value, this may change in the future. 🤞
Oh, that's probably what I did wrong, I just had
opt-level=s
, notopt-level="s"
The error wasn't interesting, it was about how it tried to import the index, but the file wasn't there. I'm 90% sure it originated in the browser and that the server was just echoing it for me to see. Other than that, it just said "build failed". Which is interesting, because when I set it to
opt-level=5
, it told me that the only valid values were 1-3, and s and z, so it's a bit surprising that I didn't get that error again).