Skip to content

Commit 5dcaf9a

Browse files
committed
runtime: add GOEXPERIMENT=runtimefree
This CL is part of a series of CLs to triangulate between the runtime, compiler, and standard library to reduce how much work the GC must do. An overall design document is in CL 700255. This CL stack implements a runtime.free within the runtime, and then uses it via automatic calls inserted by the compiler when the compiler proves it is safe to do so. In the future, we can also consider possibly a limited set of explicit calls from certain low-level portions of the standard library. When called, runtime.free allows immediate reuse of memory without waiting for a GC cycle. The goals include less overall CPU usage by the GC, longer times between GC cycles (with less overall time with the write barrier enabled), and more cache-friendly allocations for user code. Here, we just add the GOEXPERIMENT=runtimefree flag. It currently defaults to on, but can be disabled with GOEXPERIMENT=noruntimefree. The actual implementation starts in CL 673695. Updates golang#74299 Change-Id: I2f1f04dbdca51f4aaa735fd65bb2719c298d922e Reviewed-on: https://go-review.googlesource.com/c/go/+/700235 Reviewed-by: David Chase <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent d7a52f9 commit 5dcaf9a

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/internal/buildcfg/exp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (*ExperimentFlags, error) {
8383
RegabiArgs: regabiSupported,
8484
Dwarf5: dwarf5Supported,
8585
RandomizedHeapBase64: true,
86+
RuntimeFree: true,
8687
SizeSpecializedMalloc: true,
8788
GreenTeaGC: true,
8889
}

src/internal/goexperiment/exp_runtimefree_off.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/goexperiment/exp_runtimefree_on.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/goexperiment/flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ type Flags struct {
113113
// platforms.
114114
RandomizedHeapBase64 bool
115115

116+
// RuntimeFree enables the runtime to free and reuse memory more eagerly in some circumstances with compiler help.
117+
RuntimeFree bool
118+
116119
// SizeSpecializedMalloc enables malloc implementations that are specialized per size class.
117120
SizeSpecializedMalloc bool
118121

0 commit comments

Comments
 (0)