Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

go doc consuming CPU #2152

Closed
aplsek opened this issue Nov 27, 2018 · 14 comments
Closed

go doc consuming CPU #2152

aplsek opened this issue Nov 27, 2018 · 14 comments

Comments

@aplsek
Copy link

aplsek commented Nov 27, 2018

I am seeing high CPU consumed by the 'doc' subprocesses. This started happening in the last two weeks after the latest release. The following 4 processes are spawned as soon as I start typing into a .go file, I have a single editor window opened:

screen shot 2018-11-26 at 10 19 33 pm

Visual Studio Version: 1.25.0-insider
Go plugin: 0.7.0

Is there a way howto disable go doc or howto analyze this further?

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 27, 2018

As far as I know, the Go extension doesn't use any tool called doc. In the recent release, we did start using go doc though, but that should have shown up as go not doc

Can you disable all other extensions and see if you still see the issue?

@aplsek aplsek changed the title doc consuming CPU go doc consuming CPU Nov 27, 2018
@aplsek
Copy link
Author

aplsek commented Nov 27, 2018

The 'doc' in Activity Monitor represents a go doc process. See my ps output, its spawn by Visual Code:

501  5736 94581   0 10:22AM ??         0:00.03 /usr/local/bin/go doc -c -cmd -u github..... Foo
501 94581 94580   0  9:41AM ??         0:05.51 /private/var/folders/07/2nk35j995fx2hjw9zkhhlwn40000gn/T/AppTranslocation/7BC4D181-308D-4B83-956E-1E0374DC5EAE/d/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper.app/Contents/MacOS/Code - Insiders Helper /private/var/folders/07/2nk35j995fx2hjw9zkhhlwn40000gn/T/AppTranslocation/7BC4D181-308D-4B83-956E-1E0374DC5EAE/d/Visual Studio Code - Insiders.app/Contents/Resources/app/out/bootstrap --type=extensionHost 

@ramya-rao-a
Copy link
Contributor

@aplsek doc is an argument for the go command, so wouldn't the Activity Monitor have the process name as go instead of doc?

Select the process in the Activity Monitor, and then select the "info" button on the top, that will open up a detailed view which will have the parent information. Check if the processes with the process name doc have VS Code as the parent.

Another thing to try is to run Developer: Open Process Explorer in VS Code. This will open the process explorer and any high CPU consuming processes will show up there

@grillbiff
Copy link

grillbiff commented Dec 4, 2018

Hi, I'm experiencing the same problem. Here is the process chain of one of the doc processes. Couldn't see anything strange in the process explorer though
image
Two processes with a common parent down the line.

@ramya-rao-a
Copy link
Contributor

Thanks for that @grillbiff. These are for doc processes as shown in the screenshot in
#2152 (comment)?

We use go doc for 2 features:

  • The information you see when you hover on code text.
  • The information you see on the side in the auto-completion widget.

Lets try and disable these 2 features and see if that helps your case.

For the first feature, lets use gogetdoc instead of go doc for the hover info

  • Add the setting "go.docsTool": "gogetdoc"
  • Run the command Go: Install/Update tools
  • Select gogetdoc and press Ok to install it

For the second feature, if you are seeing the documentation on the side like in the below picture, press Ctrl+Space to hide it.

screen shot 2018-12-05 at 10 36 51 am

@grillbiff
Copy link

Hi,
yes my image is for two of the doc processes shown in #2152 (comment).

I tried changing to both gogetdoc and guru but no luck, still creating a lot of doc processes.

@ramya-rao-a
Copy link
Contributor

@grillbiff Also ensure that the docs side of the completions are not expanded.

@grillbiff
Copy link

@ramya-rao-a I think it has been disabled, the documentation does not appear unless I explicitly press the small info icon

@grillbiff
Copy link

image

I still get alot of doc processes. Could it be that VSCode is using godoc regardless of my choice?

@ramya-rao-a
Copy link
Contributor

Ah! My mistake.

So, VS Code always calls resolveCompletionItem for each completion item in focus whether it is expanded for docs or not.

The Go extension which implements this resolveCompletionItem calls go doc to fetch the docs and return it to VS Code which then displays it to you.

I was under the assumption that this resolveCompletionItem is only called when the docs section is expanded.

I have pushed a fix for this. Can you try it out?

  • First install the beta-version of this extension
  • Update the go.gocodeFlags setting as below
"go.gocodeFlags": [
		"-builtin",
		"-ignore-case",
		"-unimported-packages",
                "-exclude-docs"
	]

The first 3 are flags that will get passed to gocode to give us the completions. The last one will be used by the Go extension to not run go doc to get the docs.

Remember to kill all existing processes for go doc before trying this out.

@grillbiff
Copy link

Hi,
installed the fix and use -exclude-docs which seems to work. VSCode no longer creates multiple doc processes. Tested with both godoc and gogetdoc and both works fine so maybe the issue was with the resolveCompletionItem all along?

@ramya-rao-a
Copy link
Contributor

Thats right @grillbiff

@aplsek
Copy link
Author

aplsek commented Jan 25, 2019

Hi,

Is there an ETA on when the fix is going to be part of the official release?

Not sure I want to install beta-version of the plugin as that would block the future updates...

Thanks!

@ramya-rao-a
Copy link
Contributor

The latest update (0.9.1) to the extension has this fix.

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants