Reduce binary size
kareemmahlees opened this issue · comments
Context
Currently, MetaX is being used as a sidecar ( an additional binary ) alongside TableX.
Previously before MetaX, the bundle size of TableX was about 10 MB, Now after adding MetaX I noticed it became 29 MB !!
Weirdly, MetaX ( a CLI application ) is larger than TableX ( a Desktop application with NextJs + Rust + the additional dependencies of both ).
Possible Solution
related StackOverflow question.
I think the solution here is to remove all the unnecessary 3rd dependencies if they can be replaced with std libs, and possibly remove all the usage of big-sized, unused std libs such as fmt
Maybe in the future also we can migrate to using the net/http
package since it has very useful updates in go 1.22
Actually, after a bit of research, I found out about the -ldflags
flag.
After trying with this -ldflags "-w"
the binary size went from 55MB
to 33MB
, and then after trying with this -ldflags "-w -s"
the size went from 33MB
to 26MB
🔥 .
I am going to update the workflow as well as clean some fmt
s and add some logging to the tests.