#Different contract size different computer

39 messages · Page 1 of 1 (latest)

wheat jacinth
#

I'm building a contract I've written on two different macOS machines, and the output file size is remarkably different. 25KB on one, and 12KB on the other.

#

Both mac's, both Rust 1.73.0. One is an M1MAX, and the other is an M2.

balmy ore
#

are there any default settings from system env?

woeful talon
#

Is this pre or post optimization?

wheat jacinth
#

Post, but even pre optimization the diff is about the same. 29K and 15K.

woeful talon
#

I have an intel mac, I'd be happy to give it a shot and see if that varies too

wheat jacinth
#

Both systems have synchronized system environment via a git repo that's identical on both, so the bash setup and env vars are the same. These are the only Rust and Cargo params.

CARGO_UNSTABLE_SPARSE_REGISTRY=true
RUSTUP_INIT_SKIP_PATH_CHECK=yes
RUSTC_WRAPPER=/opt/homebrew/bin/sccache
#

Oh, it's possible sccache is newer on the M2...

#

Oh wow, 0.3.3 vs 0.5.3.

#

Upgrading both to 0.5.4 made no difference.

#

@halcyon timber Do you have any tips for how to debug something like this? Is there a way for me to see if LTO is actually running?

wheat jacinth
#

I'm using soroban-cli v20.0.0-rc3.

#

Both mac's are running macOS Sonoma 14.0.

woeful talon
#

Will upgrade cli. I'm on ventura still tho. One sec while i go clone and build everything

wheat jacinth
#

It's a tiny contract.

#

Although it does a little JSON decoding in the contract 😬. But the contract and deps are pretty light.

woeful talon
#
Writing to: ./out/webauthn_account_ed25519.optimized.wasm...
Optimized: ./out/webauthn_account_ed25519.optimized.wasm (25327 bytes)
-rw-r--r--  1 mootz12  staff    25K Oct  9 13:55 ./out/webauthn_account_ed25519.optimized.wasm
-rwxr-xr-x  1 mootz12  staff    29K Oct  9 13:55 ./out/webauthn_account_ed25519.wasm```
wheat jacinth
#

That's the same as what I get on my M1 Max.

woeful talon
#

if it matters, I don't have deno installed on my machine, nor do I think I have sccache

wheat jacinth
#

That shouldn't matter. Sccache just caches Rust artifacts so that builds of the same inputs across multiple repos are shared. If anything it'd be more likely to cause a problem than make everything smaller.

#

If anyone else has an Apple M2, would be interesting to see if there's something there. Otherwise, maybe I can rent out compile time on my laptop 😂

woeful talon
#

cc: @fast inlet (you have an M2, right?)

fast inlet
#

No I've got a M1

woeful talon
fast inlet
#

No problem!

balmy ore
#

I've tried Windows just for fun and got 29K non-optimized. I've noticed this in the Wasm though:
Stream ended while parsing JSON Ð  C:\Users\dmytr\.cargo\registry\src\index.crates.io-6f17d22bba15001f\microjson-0.1.2\src\lib.rs. it's pretty suspicious that compiler embeds some local paths into output (could be a red herring though...)

bronze edge
#

It must be related to the compiler build for different architectures? Maybe theres a setting to use relative paths instead. Do u have the same cargo.toml with the same build options set

woeful talon
hexed sable
#

I have an M1 Max and got 12,721 bytes on the optimized

wheat jacinth
#

I looked through its code and it has no deps, and has no cfg's based on host architecture, so maybe not.

#

I'm concerned this is something like LTO isn't running properly. cc @halcyon timber

wheat jacinth
wheat jacinth
#

It still works. I've got an integration test that loads the wasm file and tests it.

bronze edge
#

Are you using the same version of rustc on both computers

wheat jacinth
#

Yup 1.73.0

bronze edge
#

And the build configs the same? What other deps does cargo require. Could it be something like with gcc theres that posix flag for example