-
Notifications
You must be signed in to change notification settings - Fork 97
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
chore: Upgrade RTS Dependencies #4677
base: master
Are you sure you want to change the base?
Conversation
* Patch Rust for shared Wasm libraries * Get rid of `musl` * Further simplify Wasm linking * Update benchmark results * No longer need `wasm-ld` patch * Update test result * Add distinction for Linux Ocaml build * Revert "No longer need `wasm-ld` patch" This reverts commit 3d0f34e. * Revert "Update test result" This reverts commit 8fc5c08. * Use patched wasm-ld during Rust build * Table offset must be at least 1 for Rust RTS * Adjust linker test result * Use bulk memory operations * Do not need `wasm-lld` patch with shared targets * Adjust expected test result * Adjust nix build script * Fix nix build script
Size compression is no longer needed for the specific Rust target backends. This is the latest perf diff on CI (locally repeated):
|
According to the GC benchmark, it seems that this upgrade/cleanup even improves performance:
|
"branch": "next-moc", | ||
"branch": "pull/589/head", | ||
"description": "The Motoko base library", | ||
"homepage": "", | ||
"owner": "dfinity", | ||
"repo": "motoko-base", | ||
"rev": "21a80ab250501a5de3365114abb242559573fecc", | ||
"sha256": "0zm60azafdfczdiqkqs1fwgxf3crb2bk0vs7y09rvnwkqgqkxxw8", | ||
"rev": "1bece926bfc417db5661c66d8617f6b09ab06b95", | ||
"sha256": "02i8s4ybjmbbf72jclpvqcsxh4dypgsxqsagiga64jqyprmqzvlr", | ||
"type": "tarball", | ||
"url": "https://github.com/dfinity/motoko-base/archive/21a80ab250501a5de3365114abb242559573fecc.tar.gz", | ||
"url": "https://github.com/dfinity/motoko-base/archive/1bece926bfc417db5661c66d8617f6b09ab06b95.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to be changed back to next-moc
once dfinity/motoko-base#589 is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not forget this
@@ -78,7 +78,7 @@ let | |||
}; | |||
}; | |||
|
|||
# No testing of atdgen, as it pulls in python stuff, tricky on musl | |||
# No testing of atdgen, as it pulls in python stuff | |||
atdgen = super.ocamlPackages.atdgen.overrideAttrs { doCheck = false; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be doCheck = true
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or rather leave it uncustomized?
in rec { | ||
rustc-nightly = rust-channel.rust.override { | ||
targets = [ | ||
"wasm32-unknown-emscripten" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, why were these here?
# pulls in clang (wrapped) and clang-13 (unwrapped) | ||
llvmPackages_13.clang | ||
# pulls in wasm-ld | ||
llvmPackages_13.lld |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this package now merged into bintools
? We do use wasm-ld-18
below...
|
||
use motoko_rts_macros::{classical_persistence, enhanced_orthogonal_persistence}; | ||
// The meaning of the `mode` parameter is documented in motoko-base, function Float.format() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice move!
List.filter (fun import -> not (is_got import.it.module_name)) imports | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List.filter (fun import -> not (is_got import.it.module_name)) imports | |
List.filter (fun import -> not (is_got import.it.module_name)) imports |
added newline removed
@@ -915,7 +916,7 @@ let encode (em : extended_module) = | |||
patch s (p + 1) (lsb (n lsr 8)); | |||
patch s (p + 2) (lsb (n lsr 16)); | |||
patch s (p + 3) (lsb (n lsr 24)) | |||
let dw_patches = ref Fun.id | |||
let dw_patches = ref (fun i -> i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Heroic work on the dylink0
stuff. Being stuck on clang-13
gave me nightmares...
Nice to see the cycle improvements too. Getting rid of musl
means one less wheel to maintain.
Good work! Added a few Qs...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Not sure I fully understand the intricacies so 🤞
"branch": "next-moc", | ||
"branch": "pull/589/head", | ||
"description": "The Motoko base library", | ||
"homepage": "", | ||
"owner": "dfinity", | ||
"repo": "motoko-base", | ||
"rev": "21a80ab250501a5de3365114abb242559573fecc", | ||
"sha256": "0zm60azafdfczdiqkqs1fwgxf3crb2bk0vs7y09rvnwkqgqkxxw8", | ||
"rev": "1bece926bfc417db5661c66d8617f6b09ab06b95", | ||
"sha256": "02i8s4ybjmbbf72jclpvqcsxh4dypgsxqsagiga64jqyprmqzvlr", | ||
"type": "tarball", | ||
"url": "https://github.com/dfinity/motoko-base/archive/21a80ab250501a5de3365114abb242559573fecc.tar.gz", | ||
"url": "https://github.com/dfinity/motoko-base/archive/1bece926bfc417db5661c66d8617f6b09ab06b95.tar.gz", | ||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not forget this
@@ -41,33 +40,3 @@ unsafe impl GlobalAlloc for EphemeralAllocator { | |||
|
|||
#[global_allocator] | |||
static ALLOCATOR: EphemeralAllocator = EphemeralAllocator; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this stuff need for musl and that's why we can remove it?
if imports = [] then | ||
m | ||
(* Computes the absolute address of the GOT.mem data pointer *) | ||
let data_pointer exported_global_index = if uses_memory64 m then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that you should do this now, but I wonder if it would be possible to just bump the (mutable?) globals by the offset using an initialization function, rather than recomputing the absolute address at each read. Another advantage, apart from perf, would be that any debug info would remain valid (rather than disturbing the instruction offset in the code.
For each `GOT.mem`, we replace the GOT accesses in the AST by code that computes | ||
the absolute address of the data. This is the library's memory base plus the | ||
relative data offset stored in the global as determined in the first step. | ||
The `GOT.mem` import is replaced by a dummy global that only serves to maintain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the dummy global could instead hold the absolute/resolved address, and we replace references to the import by references to the resolved global? But I don't fully understand this stuff..
Upgrading Motoko RTS dependencies:
Special aspects:
dylink.0
instead ofdylink
.GOT.mem
for RTS in the Motoko linker.emscripten
: Use custom Rust targets .emscripten
by using custom Rust targets for generating PIC-relocatable Wasm.musl
by using Rust builtins instead.musl
: The output format ofNaN
andinfinity
has changed. Moreover, one particular output format (hexadecimal float) is no longer supported. Updating the documentation and base library is needed.musl
.Note:
nix-shell
crashes with a segmentation fault with this PR, you need to upgradenix
. For this, you need to manually uninstall and re-installnix
.TODO:
motoko-base
dependency back to next-moc.