Repository navigation
fix(compute): remove hardcoded -gc flag from the tinygo build command - #1926
Conversation
For tinygo binaries before version 0.34, the default is `-gc=conservative`. version 0.34 swapped the default to precise. Dropping the gc flag completely preserves the current behavior for users on older tinygo versions, and switches to the precise collector for newer tinygo. When benchmarked within viceroy, the change generally results in a faster binary and the same memory usage, but under some workloads (that allocate lots of small pointer-heavy objects) the peak memory usage can be higher. The reason seems to be explained by the commit message that introduces the collector, which says “It does however use a bit more RAM to store the layout of each object”. Workloads which care about memory usage more than execution speed can revert this change by adding a build script to their `fastly.toml`: `build = "tinygo build -target=wasi -gc=conservative -o bin/main.wasm ./"`
c8dd090 to
846837d
Compare
-gc flag from the tinygo build command-gc flag from the tinygo build command
rcaril
left a comment
There was a problem hiding this comment.
Looks good, thanks for the clear explanation!
Should we consider adding a test scenario to TestBuildGo with no [script] block to exercise the TinyGo fallback?
It looks like CI still installs tinygo 0.31.2, so the default will still be conservative. A test that checks the fallback is still useful though. |
|
Please keep in mind that our starter kit (https://github.com/fastly/compute-starter-kits/blob/5024939c7297c9705b5693193ec3cba1f2346b8b/starter-kits/go/tinygo/fastly.toml#L12) specifies the build command directly and doesn't include this flag, so this change in the CLI will only affect users who built their project using an older starter kit or have removed the build command from |
It looks like the starter kit already excludes the |
|
So it turns out we didn't have any tests which used tinygo prior to the one I just added. I had run the new tests locally but I was on 0.42. The 0.31.2 version installed by CI complained that it couldn't be used alongside go 1.26.x also installed by CI, which showed up with this change because tinygo was actually called in a test. I've bumped the CI version to account for this. |
|
👍 The precise collector is much better than the conservative one. |
Change summary
For tinygo binaries before version 0.34, the default is
-gc=conservative. version 0.34 swapped the default to precise. Dropping the gc flag completely preserves the current behavior for users on older tinygo versions, and switches to the precise collector for newer tinygo.When benchmarked within viceroy, the change generally results in a faster binary and the same memory usage, but under some workloads (that allocate lots of small pointer-heavy objects) the peak memory usage can be higher. The reason seems to be explained by the commit message that introduces the collector, which says “It does however use a bit more RAM to store the layout of each object”.
Workloads which care about memory usage more than execution speed can revert this change by adding a build script to their
fastly.toml:build = "tinygo build -target=wasi -gc=conservative -o bin/main.wasm ./"Also note that this change only affects users who do not currently have a build script in their fastly.toml file. The current tinygo starter kit already provides a build script which is identical to this change.
See PR #1917 and issue #1480.
Fixes #1480
All Submissions:
New Feature Submissions:
Changes to Core Features:
User Impact
Changes the collector used to
precisefor users oftinygo>=0.34Are there any considerations that need to be addressed for release?