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

Binary size #252

Open
Wieku opened this issue Feb 22, 2024 · 4 comments
Open

Binary size #252

Wieku opened this issue Feb 22, 2024 · 4 comments
Labels
enhancement New feature or request investigating Searching for origins of the issue.

Comments

@Wieku
Copy link
Contributor

Wieku commented Feb 22, 2024

I'm migrating my code from https://github.com/inkyblackness/imgui-go (more specifically https://github.com/neclepsio/imgui-go I use as replacement) and was taken by surprise that release build (-s -w ldflags) of my program with cimgui-go now weights ~7.5MB more:

  • no imgui used: 13.1MB
  • inkyblackness imgui: 15.2MB (code using imgui is 6.2K LoC so impact is minimal)
  • cimgui-go: 22.7MB (built with -tags "exclude_cimgui_glfw exclude_cimgui_sdli")

Debug build increased from 44.8MB to 61.8MB:

All built with go 1.21.0, gcc/g++ 12.2.0-msvcrt-posix-seh via winlibs.

I don't think implot and immarkdown adds so much so something else is happening but cgo/c/c++ ecosystem is a dark magic to me to figure out what.

@gucio321 gucio321 mentioned this issue Feb 26, 2024
@gucio321
Copy link
Collaborator

@Wieku maybe its because we also use imnodes and imgui_markdown...
anyway, consider the following:

[cimgui-go (0) ]$ du -hs  lib/linux/x64/*
6.8M	lib/linux/x64/cimgui.a
4.0K	lib/linux/x64/dummy.go
472K	lib/linux/x64/libglfw3.a
5.2M	lib/linux/x64/libSDL2.a

idk when (in "code history") this issue was opened, maybe your code include sdl unnecessarily?

@Wieku
Copy link
Contributor Author

Wieku commented Sep 24, 2024

@gucio321 I will test over the weekend with a new version, but at the time I was building it with -tags "exclude_cimgui_glfw exclude_cimgui_sdli"

My theory is that because it links statically to the ".a" library it's not stripping unused symbols? IIRC inklyblackness' one is building imgui during the package build.

@Wieku
Copy link
Contributor Author

Wieku commented Sep 24, 2024

@gucio321 I've ported the app to v1.0.0. I've done a symbol export via DLL Export Viewer and all imgui symbols are exported:
exported-cimgui.txt

vs inky, which has only select functions exported:
exported-inky.txt

So not stripping theory kinda makes sense I think?

I see ~600KB reduction in release build, which in reality is a bit bigger considering fresh build has new code and uses go 1.23.

Just for funzies I've ran goweight on v1.0.0, and there's some reduction, but still the size seems kinda excessive:
image

@gucio321
Copy link
Collaborator

sound reasonable.
I'm a bit afraid to touch this C/C++ sructure in our project as it somehow works.
but this would be something we might want to do in a future.

@gucio321 gucio321 added enhancement New feature or request investigating Searching for origins of the issue. labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request investigating Searching for origins of the issue.
Projects
None yet
Development

No branches or pull requests

2 participants