Skip to content

Commit c8aaec2

Browse files
committed
runtime/trace: also treat plan9 as a low memory system
Fixes #31554 Updates #12032 (also originally about plan9, but later openbsd/arm) Change-Id: Ib9f35d27a2304f38bf271c38c0b9153d210d8f95 Reviewed-on: https://go-review.googlesource.com/c/go/+/172837 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 02bd0fd commit c8aaec2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Diff for: src/runtime/trace/trace_test.go

+18-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func TestTraceStress(t *testing.T) {
237237
runtime.GC()
238238
// Trigger GC from malloc.
239239
n := int(1e3)
240-
if runtime.GOOS == "openbsd" && runtime.GOARCH == "arm" {
240+
if isMemoryConstrained() {
241241
// Reduce allocation to avoid running out of
242242
// memory on the builder - see issue/12032.
243243
n = 512
@@ -322,6 +322,21 @@ func TestTraceStress(t *testing.T) {
322322
testBrokenTimestamps(t, trace)
323323
}
324324

325+
// isMemoryConstrained reports whether the current machine is likely
326+
// to be memory constrained.
327+
// This was originally for the openbsd/arm builder (Issue 12032).
328+
// TODO: move this to testenv? Make this look at memory? Look at GO_BUILDER_NAME?
329+
func isMemoryConstrained() bool {
330+
if runtime.GOOS == "plan9" {
331+
return true
332+
}
333+
switch runtime.GOARCH {
334+
case "arm", "mips", "mipsle":
335+
return true
336+
}
337+
return false
338+
}
339+
325340
// Do a bunch of various stuff (timers, GC, network, etc) in a separate goroutine.
326341
// And concurrently with all that start/stop trace 3 times.
327342
func TestTraceStressStartStop(t *testing.T) {
@@ -381,9 +396,9 @@ func TestTraceStressStartStop(t *testing.T) {
381396
runtime.GC()
382397
// Trigger GC from malloc.
383398
n := int(1e3)
384-
if runtime.GOOS == "openbsd" && runtime.GOARCH == "arm" {
399+
if isMemoryConstrained() {
385400
// Reduce allocation to avoid running out of
386-
// memory on the builder - see issue/12032.
401+
// memory on the builder.
387402
n = 512
388403
}
389404
for i := 0; i < n; i++ {

0 commit comments

Comments
 (0)