News for hackers. Stuff that matters.
Re:Go 1.21 Released by febstar on Tuesday August 08, 2023 @04:05PM (#37054760)
Seems to be the smallest Go release yet (at least since 1.4). I wonder how the binary size was reduced in the recent two versions?

   1.21    63MB
   1.20    95MB
   1.19   142MB
   1.18   135MB
   1.17   129MB
   1.16   123MB
   1.15   116MB
   1.14   118MB
   1.13   114MB
   1.12   121MB
   1.11   121MB
   1.10   114MB
   1.9     98MB
   1.8     86MB
   1.7     78MB
   1.6     81MB
   1.5     74MB
(linux-amd64 archives from https://go.dev/dl/)
Re:Go 1.21 Released by FiloSottile on Tuesday August 08, 2023 @04:39PM (#37055154)
Long term intentional effort: https://go.dev/issue/27151
Re:Go 1.21 Released by tough on Tuesday August 08, 2023 @04:52PM (#37055285)
All I could find for context about what caused it (which is not reflected in that issue)

> Go command The directory $GOROOT/pkg no longer stores pre-compiled package archives for the standard library: go install no longer writes them, the go build no longer checks for them, and the Go distribution no longer ships them. Instead, packages in the standard library are built as needed and cached in the build cache, just like packages outside GOROOT. This change reduces the size of the Go distribution and also avoids C toolchain skew for packages that use cgo.

https://tip.golang.org/doc/go1.20

Re:Go 1.21 Released by Someone on Tuesday August 08, 2023 @04:44PM (#37055196)
Possibly compiler/linker improvements. For example, FTA:

“In Go 1.21 the linker (with help from the compiler) is now capable of deleting dead (unreferenced) global map variables, if the number of entries in the variable initializer is sufficiently large, and if the initializer expressions are side-effect free.”

There also may be differences in debug symbols in the various binaries.

Re:Go 1.21 Released by 38 on Tuesday August 08, 2023 @04:56PM (#37055334)
Other two comments are wrong. The correct answer is that the compiler now builds everything on demand if it's not already built. This now includes the standard library as well. Previously built versions of standard library modules were being shipped.
Re:Go 1.21 Released by mighmi on Tuesday August 08, 2023 @07:30PM (#37056851)
It seems like it rebuilds itself with PGO. I can't tell if I'm being paranoid/didn't only include stdlib in something, but I ran some random programs, restarted my computer and the install is now at 320mb, vs. 213 when I first untarred it.

https://go.dev/doc/pgo

> PGO in Go applies to the entire program. All packages are rebuilt to consider potential profile-guided optimizations, including standard library packages.

Re:Go 1.21 Released by 38 on Tuesday August 08, 2023 @07:54PM (#37057050)
PGO is opt in, just like Rust. you have to explicitly tell the compiler that you want to use it.
Re:Go 1.21 Released by yencabulator on Saturday August 12, 2023 @05:23PM (#37104350)
Go1.21 uses PGO by default, if the file default.pgo exists.

> The -pgo build flag now defaults to -pgo=auto, and the restriction of specifying a single main package on the command line is now removed. If a file named default.pgo is present in the main package's directory, the go command will use it to enable profile-guided optimization for building the corresponding program.