diff --git a/cmd/tsgo/main.go b/cmd/tsgo/main.go index 8d6816fa3d4..f264cc32a8f 100644 --- a/cmd/tsgo/main.go +++ b/cmd/tsgo/main.go @@ -16,6 +16,8 @@ func main() { func runMain() int { core.ApplyDebugStackLimit() + core.ApplyDefaultGOGC() + args := os.Args[1:] if len(args) > 0 { switch args[0] { diff --git a/internal/core/core.go b/internal/core/core.go index 1ce98a8c744..22e4c62617a 100644 --- a/internal/core/core.go +++ b/internal/core/core.go @@ -33,6 +33,14 @@ func ApplyDebugStackLimit() { rtdebug.SetMaxStack(n) } +func ApplyDefaultGOGC() { + v := os.Getenv("GOGC") //nolint:forbidigo + if v != "" { + return + } + rtdebug.SetGCPercent(50) +} + func Filter[T any](slice []T, f func(T) bool) []T { for i, value := range slice { if !f(value) {