mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG]: Mojo hello world binary size unreasonably large

Open albancolley opened this issue 1 year ago • 2 comments

Bug description

Binary file large in mojo 0.7.0

Reoccurrence of BUG https://github.com/modularml/mojo/issues/599 which was resolved in 0.3.0.

Steps to reproduce

image

System information

WSL2 - Ubuntu 22.04.3 LTS
mojo 0.7.0 (af002202)
modular 0.4.1 (2d8afe15)

albancolley avatar Feb 14 '24 17:02 albancolley

a whopping 4 megabytes before stripping, and 544KB after, here

mojo 0.7.0 (af002202), archlinux

treeshateorcs avatar Feb 18 '24 21:02 treeshateorcs

woof, thanks for filing! We'll take a look at the stripping flags in binary generation

River707 avatar Feb 20 '24 19:02 River707

Looks like it was fixed in 24.1. On my Mac the binary size is 533 KB after build and 355 KB after strip hello

toiletsandpaper avatar Mar 13 '24 08:03 toiletsandpaper

Yep, this should be fixed now! Please re-open if you still see if you see this again!

River707 avatar Apr 03 '24 20:04 River707

Thanks River. However, doesn't the comment from @toiletsandpaper imply that it's Not fixed? If we need to use the strip command to decrease the binary further, then that means there are still unnecessary symbols making the binary larger?

On macOS, I get a size of 272K for a simple hello.mojo program on version 2024.4.117 (8f6529b0). Then after using strip command the binary is further reduced to 208K.

Could you please clarify if the presence of unnecessary symbols is still an issue?

SimplyYummy avatar Apr 03 '24 21:04 SimplyYummy

Yeah, we may have some symbols that could still be stripped further, we'll need to investigate which symbols those are exactly. I marked this as fixed for the original underlying issue of being "unreasonably large"(the several mb was the big issue, digging into the last 60kb is not as pressing). We should open another issue to explore that last mile, but it's good to keep that exploration separate (we do have some symbols that only get used in certain scenarios, but we should certainly try to strip out all symbols that definitely won't be needed).

River707 avatar Apr 03 '24 21:04 River707

Ah got it. That makes sense. Thanks for clarifying!

SimplyYummy avatar Apr 03 '24 22:04 SimplyYummy

seems to re-appearing in v24.2.1 @River707

cat world.mojo 
fn main():
    print("Hello world")
$ mojo --version
mojo 24.2.1 (2f0dcf11)
$ mojo build world.mojo
$ ./world 
Hello world
$ du -hs world.mojo 
4.0K	world.mojo
$ du -hs world
4.3M	world
$ uname -a
Linux pop-os 6.8.0-76060800daily20240311-generic #202403110203~1713206908~22.04~3a62479 SMP PREEMPT_DYNAMIC Mon A x86_64 x86_64 x86_64 GNU/Linux


On linux the binary size for hello world is 4.3MB by default

vrakesh avatar Apr 26 '24 23:04 vrakesh