golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.74k stars 17.5k forks source link

misc/wasm: importing fmt adds ~500kb to the binary #29478

Closed OneOfOne closed 5 years ago

OneOfOne commented 5 years ago

What version of Go are you using (go version)?

$ go version
go version devel +bfaf11c158 2018-12-26 05:21:41 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ GOOS=js GOARCH=wasm go env                                              
GOARCH="wasm"
GOBIN="/home/oneofone/code/go/bin"
GOCACHE="/tmp/.gocache"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="js"
GOPATH="/home/oneofone/code/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/src/go"
GOTMPDIR=""
GOTOOLDIR="/usr/src/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build733631578=/tmp/go-build -gno-record-gcc-switches"

This isn't a bug per-se, but I think maybe something can be done to improve that.

Feel free to close it or keep it as a reminder for later.

neelance commented 5 years ago

I fully agree that the binary sizes are large measured by current web standards. So far, binary size hasn't been one of the main concerns of Go due to the main use cases it currently has. With WebAssembly this changes and we will see how much influence this will have on Go in the future.

6853 already covers this issue and I don't see anything immediate we can do specifically for WebAssembly, so let's close this as a duplicate.

Also please always look at the size difference with gzip applied, since this is the only size that really matters. With gzip, a quick experiment shows for me a difference of 1.1MB non-gzipped, but only 230KB gzipped.

techtonik commented 5 years ago

6853 is CFC. 230Kb gzipped is still big. How much is it in memory when running on web page context?

neelance commented 5 years ago

For memory related issues see #27462