Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: cannot find a runnable goroutine in a period of time #50498

Closed
WangLeonard opened this issue Jan 7, 2022 · 0 comments
Closed

runtime: cannot find a runnable goroutine in a period of time #50498

WangLeonard opened this issue Jan 7, 2022 · 0 comments

Comments

@WangLeonard
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go1.16.8 linux/amd64

Does this issue reproduce with the latest release?

I think it can, but the probability is lower

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"

What did you do?

A test from https://go-review.googlesource.com/c/go/+/227767/3

package main_test

import (
	"runtime"
	"testing"
)

var (
	setGCPercentBallast interface{}
	setGCPercentSink    interface{}
)

func TestGC(t *testing.T) {
	defer func() {
		setGCPercentBallast = nil
		setGCPercentSink = nil
		runtime.GC()
	}()

	runtime.GC()
	var m1 runtime.MemStats
	runtime.ReadMemStats(&m1)

	// Create 50 MB of live heap as a baseline.
	const baseline = 50 << 20
	setGCPercentBallast = make([]byte, baseline-m1.Alloc)
	// Disable GOGC-based policy.
	// Set max heap to 2x baseline.
	const limit = 2 * baseline

	// Allocate a bunch and check that we stay under the limit.
	runtime.ReadMemStats(&m1)
	var m2 runtime.MemStats
	for i := 0; i < 200; i++ {
		setGCPercentSink = make([]byte, 1<<20)
		runtime.ReadMemStats(&m2)
		if m2.HeapAlloc > limit {
			t.Logf("HeapAlloc %d exceeds heap limit %d\n", m2.HeapAlloc, limit)
		}
	}
	if m1.NumGC == m2.NumGC {
		t.Fatalf("failed to trigger GC")
	}
}
go test -c -o test_1.16    
GODEBUG=gctrace=1 ./test_1.16 -test.count=10 -test.trace=16_trace_1  -test.run ^TestGC$

What did you expect to see?

What did you see instead?

Probably reproduce the following problems
In gcStart -> StopTheWorld -> finishsweep_m -> wakeScavenger
and runtime.bgscavenge is an runnable goroutine,
After StartTheWorkld, Proc1 cannot find it to execute in multiple proc start proc stop
It seems that findrunnable cannot find/steal this goroutine
go1.16.8
image
gomaster
image
image

trace.zip

@WangLeonard WangLeonard changed the title runtime: cannot find a runnable goroutine runtime: cannot find a runnable goroutine in a period of time Jan 7, 2022
@golang golang locked and limited conversation to collaborators Jan 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants