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

Use Custom Rust Targets for Shared Wasm Libraries #4683

Merged
merged 17 commits into from
Oct 8, 2024

Conversation

luc-blaeser
Copy link
Contributor

@luc-blaeser luc-blaeser commented Sep 3, 2024

Simplify Motoko RTS building:

  • Use custom Rust targets for generating PIC-relocatable Wasm.
  • Get rid of emscripten or explicit compilation via LLVM IR.
  • Get rid of musl (until now, it was only used for classical persistence).
  • Optimization: Use bulk-memory operations because memcpy of Rust is slower than musl.
  • No need for the wasm-ld fix as the custom targets do not generate corresponding DSO-local relative table index relocations ([lld][WebAssembly] Fix relocation of Wasm table index with GOT access llvm/llvm-project#104043).

Copy link

github-actions bot commented Sep 6, 2024

Comparing from a6d1305 to 0b196f8:
In terms of gas, 5 tests regressed and the mean change is +0.0%.
In terms of size, 5 tests improved and the mean change is -41.1%.

@luc-blaeser luc-blaeser marked this pull request as ready for review September 9, 2024 08:09
@luc-blaeser luc-blaeser self-assigned this Sep 9, 2024
@luc-blaeser luc-blaeser changed the title Experiment: Use Custom Rust Targets for Shared Wasm Libraries Use Custom Rust Targets for Shared Wasm Libraries Sep 9, 2024
@luc-blaeser luc-blaeser added the dependencies Pull requests that update a dependency file label Sep 9, 2024
Copy link
Contributor

@crusso crusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't pretend to know what is going one but this seems like a nice cleanup removing musl from the classical compiler. Shame the instruction counts seem to go up.

ingress Completed: Reply: 0x4449444c0000
debug.print: {cycles = 105_771_809; size = +1_817_872}
debug.print: {cycles = 111_509_014; size = +1_817_872}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this has increased so much?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I need to analyze why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I analyzed it and the problem is that the Rust/LLVM builtin memcpy is way slower than musl, not using 64-bit copying. I activated bulk memory copying to get better performance.
(Bignum needs a lot of memcpy because of big integer reallocations to larger blobs.)

@luc-blaeser luc-blaeser merged commit aa445dd into luc/upgrade-rts-dependencies Oct 8, 2024
6 checks passed
@luc-blaeser luc-blaeser deleted the luc/rust-shared-target branch October 8, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants