golang / vscode-go

Go extension for Visual Studio Code

Home Page:https://marketplace.visualstudio.com/items?itemName=golang.Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test explorer about 25 times slower with many subtests

znkr opened this issue · comments

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.22.3 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.15.3
    golang.org/x/tools/gopls@v0.15.3 h1:zbdOidFrPTc8Bx0YrN5QKgJ0zCjyGi0L27sKQ/bDG5o=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/tools@v0.18.1-0.20240412183611-d92ae0781217 h1:uH9jJYgeLCvblH0S+03kFO0qUDxRkbLRLFiKVVDl7ak=
    golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: devel go1.23-890179d949 Thu Apr 11 17:09:10 2024 +0000 X:rangefunc
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • Version: 1.89.0 (Universal)
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.41.4
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: /Users/flo/go
GOROOT: /Users/flo/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64
PATH: /opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/Wireshark.app/Contents/MacOS

## Tools

	go:	/opt/homebrew/bin/go: go version go1.22.0 darwin/arm64

	gopls:	/Users/flo/go/bin/gopls	(version: v0.15.3 built with go: go1.23-890179d949)
	gotests:	/Users/flo/go/bin/gotests	(version: v1.6.0 built with go: go1.23-4a7f3ac8)
	gomodifytags:	/Users/flo/go/bin/gomodifytags	(version: v1.16.0 built with go: go1.23-4a7f3ac8)
	impl:	/Users/flo/go/bin/impl	(version: v1.1.0 built with go: go1.23-4a7f3ac8)
	goplay:	/Users/flo/go/bin/goplay	(version: v1.0.0 built with go: go1.23-4a7f3ac8)
	dlv:	/Users/flo/go/bin/dlv	(version: v1.22.1 built with go: go1.21.1)

## Go env

Workspace Folder (vccode_test_slowness_repo): /Users/flo/Projects/go/vccode_test_slowness_repo

	GO111MODULE=''
	GOARCH='arm64'
	GOBIN=''
	GOCACHE='/Users/flo/Library/Caches/go-build'
	GOENV='/Users/flo/Library/Application Support/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFLAGS=''
	GOHOSTARCH='arm64'
	GOHOSTOS='darwin'
	GOINSECURE=''
	GOMODCACHE='/Users/flo/go/pkg/mod'
	GONOPROXY='*.home.znkr.io'
	GONOSUMDB='*.home.znkr.io'
	GOOS='darwin'
	GOPATH='/Users/flo/go'
	GOPRIVATE='*.home.znkr.io'
	GOPROXY='https://proxy.golang.org,direct'
	GOROOT='/Users/flo/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.3.darwin-arm64'
	GOSUMDB='sum.golang.org'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/Users/flo/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.3.darwin-arm64/pkg/tool/darwin_arm64'
	GOVCS=''
	GOVERSION='go1.22.3'
	GCCGO='gccgo'
	AR='ar'
	CC='clang'
	CXX='clang++'
	CGO_ENABLED='1'
	GOMOD='/Users/flo/Projects/go/vccode_test_slowness_repo/go.mod'
	GOWORK=''
	CGO_CFLAGS='-O2 -g'
	CGO_CPPFLAGS=''
	CGO_CXXFLAGS='-O2 -g'
	CGO_FFLAGS='-O2 -g'
	CGO_LDFLAGS='-O2 -g'
	PKG_CONFIG='pkg-config'
	GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/1_/dsgxrj_j2ws_5h4ykmddqjyr0000gn/T/go-build2964250531=/tmp/go-build -gno-record-gcc-switches -fno-common'

Share the Go related settings you have added/edited

    "go.coverageDecorator": {
        "type": "gutter",
        "coveredHighlightColor": "rgba(64,128,128,0.5)",
        "uncoveredHighlightColor": "rgba(128,64,64,0.25)",
        "coveredBorderColor": "rgba(64,128,128,0.5)",
        "uncoveredBorderColor": "rgba(128,64,64,0.25)",
        "coveredGutterStyle": "blockblue",
        "uncoveredGutterStyle": "slashyellow"
    },
    "go.coverOnSingleTest": true,
    "go.coverOnSingleTestFile": true,
    "go.coverOnSave": true,
    "go.testOnSave": true,
    "go.testExplorer.showDynamicSubtestsInEditor": true,
    "go.testExplorer.showOutput": false,

Describe the bug

I have a project that includes thousands of tests, most of these are generated from testdata files. When I use the test explorer to run the tests it takes significantly longer to run these tests than when I run go test ./... directly. At first I thought that this might be due to caching, but turned out to be false. Even with all caches cleared, the test explorer is still a lot slower.

I recently showed the issue to @hyangah and we agreed that I file an issue here.

Steps to reproduce the behavior:

  1. Create a new project with a test file containing
func Test(t *testing.T) {
	for i := range 1000 {
		t.Run(fmt.Sprintf("test_%03d", i), func(t *testing.T) {
			// intentionally left empty
		})
	}
}
  1. Click on "Run Tests" in the test explorer to run all tests
  2. Run go test manually
  3. On my machine (M1 Macbook), the test explorer run takes about 5 seconds while the go test run takes about 0.2 seconds. I would expect that both are about the same.