Skip to content

x/tools/gopls: high cpu usage when make changes in package which have some cgo package dependents #50151

Open
@zhuah

Description

@zhuah

gopls version

Build info

golang.org/x/tools/gopls v0.7.3
golang.org/x/tools/gopls@v0.7.3 h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=
github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/google/go-cmp@v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sys@v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
golang.org/x/text@v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/tools@v0.1.8-0.20211014194737-fc98fb2abd48 h1:hk7xRoeg0CG1nRLsd5BZLDUgVpA9bnKylGk1p2/BPH0=
golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
honnef.co/go/tools@v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=

go env

What did you do?

I'm work on a monorepo with some cgo packages in VSCode, when i modify the core package that cgo packages depends on, the cpu usage goes 100%.
I have tried inspect it with

pstree `pgrep gopls`

which shows that there are several clang process created by go list and cgo command.

i must run pkill clang instantly when cpu usage goes 100%, but when i am keep editing, the cpu goes 100% again.
so i'm wondering that is there a way to disable cgo in gopls or let gopls do not compile cgo package.

What did you expect to see?

What did you see instead?

-+- 00827 zhuah /Users/zhuah/go/bin/gopls -mode=stdio
 \-+- 15602 zhuah go list -modfile=TMPDIR/go.5c768b47e65a0399512ae86c5ba9023517f92436988adbfe6f37ff2addbfa6cc.1607909778.mod -mod=readonly -overlay=TMPDIR/gopackages-2412941141/overlay.json -e -json -compiled=true -test=true -export=false -deps=true -find=false -- PACKAGELIST
   |-+- 15634 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b300/ -importpath CGOPACKAGE -- -I TMPDIR/go-build833139357/b300/ -g -O2 CGOFILE CGODIR CGOFILE CGOFILE
   | \-+- 15831 zhuah /usr/bin/clang -w -Wno-error -oTMPDIR/go-build833139357/b300//_cgo_.o -gdwarf-2 -c -ferror-limit=0 -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-function -Qunused-arguments -fno-builtin -I TMPDIR/go-build833139357/b300/ -arch x86_64 -m64 -fno-lto -O0 -fdiagnostics-color=never -I . TMPDIR/cgo-gcc-input-2621109915.c
   |   \--- 15833 zhuah /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name cgo-gcc-input-2621109915.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debug-info-kind=standalone -dwarf-version=2 -debugger-tuning=lldb -target-linker-version 609 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I TMPDIR/go-build833139357/b300/ -I . -I/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -O0 -Wno-error -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-function -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -w -fdebug-compilation-dir CGODIR -ferror-limit 0 -fmessage-length 0 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fno-builtin -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.15.0 -fmax-type-align=16 -fdiagnostics-show-option -o TMPDIR/go-build833139357/b300//_cgo_.o -x c TMPDIR/cgo-gcc-input-2621109915.c
   |-+- 15650 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b096/ -importpath CGOPACKAGE -- -I TMPDIR/go-build833139357/b096/ -g -O2 -x objective-c CGOFILE
   | \-+- 15808 zhuah /usr/bin/clang -w -Wno-error -oTMPDIR/go-build833139357/b096//_cgo_.o -gdwarf-2 -c -ferror-limit=0 -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-function -Qunused-arguments -fno-builtin -I TMPDIR/go-build833139357/b096/ -x objective-c -arch x86_64 -m64 -fno-lto -O0 -fdiagnostics-color=never -I . TMPDIR/cgo-gcc-input-556442778.c
   |   \--- 15811 zhuah /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name cgo-gcc-input-556442778.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debug-info-kind=standalone -dwarf-version=2 -debugger-tuning=lldb -target-linker-version 609 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I TMPDIR/go-build833139357/b096/ -I . -I/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -O0 -Wno-error -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-function -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -w -fdebug-compilation-dir CGODIR -ferror-limit 0 -fmessage-length 0 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fno-builtin -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.15.0 -fobjc-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o TMPDIR/go-build833139357/b096//_cgo_.o -x objective-c TMPDIR/cgo-gcc-input-556442778.c
   |-+- 15656 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b083/ -importpath CGOPACKAGE -- -I TMPDIR/go-build833139357/b083/ -g -O2 -Wno-int-to-pointer-cast CGOFILE
   | \-+- 15801 zhuah (clang)
   |   \--- 15802 zhuah (clang)
   |-+- 15657 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b126/ -importpath CGOPACKAGE -- -I TMPDIR/go-build833139357/b126/ -g -O2 -x objective-c -ICGOPACKAGE -Wno-deprecated-declarations CGOFILE
   | \-+- 15659 zhuah (clang)
   |   \--- 15665 zhuah (clang)
   |-+- 15677 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b137/ -importpath CGOPACKAGE -- -I TMPDIR/go-build833139357/b137/ -g -O2 -x objective-c CGOFILE
   | \-+- 15681 zhuah (clang)
   |   \--- 15684 zhuah (clang)
   |-+- 15746 zhuah /usr/bin/clang++ -I CGODIR -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=TMPDIR/go-build833139357/b100=/tmp/go-build -gno-record-gcc-switches -fno-common -I TMPDIR/go-build833139357/b100/ -g -O2 -std=c++2a -fno-exceptions -fno-rtti -o TMPDIR/go-build833139357/b100/_x003.o -c CPPFILE
   | \--- 15748 zhuah /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CPPFILE -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 609 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I CGODIR -I TMPDIR/go-build833139357/b100/ -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -O2 -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -std=c++2a -fdeprecated-macro -fdebug-compilation-dir CGODIR -fdebug-prefix-map=TMPDIR/go-build833139357/b100=/tmp/go-build -ferror-limit 19 -fmessage-length 0 -pthread -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fobjc-runtime=macosx-10.15.0 -fmax-type-align=16 -fno-common -fno-caret-diagnostics -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o TMPDIR/go-build833139357/b100/_x003.o -x c++ CPPFILE
   |-+- 15773 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b138/ -importpath CGOPACKAGE -- -I TMPDIR/go-build833139357/b138/ -g -O2 -x objective-c CGOFILE CGOFILE
   | \-+- 15779 zhuah /usr/bin/clang -E -dM -arch x86_64 -m64 -I TMPDIR/go-build833139357/b138/ -O2 -x objective-c -I . TMPDIR/cgo-gcc-input-2816487396.c
   |   \--- 15781 zhuah /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name cgo-gcc-input-2816487396.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 609 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I TMPDIR/go-build833139357/b138/ -I . -I/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -O2 -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -fdebug-compilation-dir CGODIR -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.15.0 -fobjc-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -vectorize-loops -vectorize-slp -dM -o - -x objective-c TMPDIR/cgo-gcc-input-2816487396.c
   \-+- 15803 zhuah /usr/local/Cellar/gotip/pkg/tool/darwin_amd64/cgo -objdir TMPDIR/go-build833139357/b075/ -importpath IMPORTPATH -- -I TMPDIR/go-build833139357/b075/ -g -O2 -Wno-deprecated-declarations -x objective-c CGOFILE
     \-+- 15810 zhuah /usr/bin/clang -w -Wno-error -oTMPDIR/go-build833139357/b075//_cgo_.o -gdwarf-2 -c -ferror-limit=0 -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-function -Qunused-arguments -fno-builtin -I TMPDIR/go-build833139357/b075/ -Wno-deprecated-declarations -x objective-c -arch x86_64 -m64 -fno-lto -O0 -fdiagnostics-color=never -I . TMPDIR/cgo-gcc-input-1994762254.c
       \--- 15813 zhuah /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name cgo-gcc-input-1994762254.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=10.15.6 -fcompatibility-qualified-id-block-type-checking -target-cpu penryn -dwarf-column-info -debug-info-kind=standalone -dwarf-version=2 -debugger-tuning=lldb -target-linker-version 609 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I TMPDIR/go-build833139357/b075/ -I . -I/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -O0 -Wno-error -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-function -Wno-deprecated-declarations -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -w -fdebug-compilation-dir CGODIR -ferror-limit 0 -fmessage-length 0 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fno-builtin -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.15.0 -fobjc-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o TMPDIR/go-build833139357/b075//_cgo_.o -x objective-c TMPDIR/cgo-gcc-input-1994762254.c

Editor and settings

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/performanceIssues related to gopls performance (CPU, memory, etc).

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions