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

godoc processes hogging cpu #687

Closed
hhrutter opened this issue Dec 11, 2016 · 17 comments
Closed

godoc processes hogging cpu #687

hhrutter opened this issue Dec 11, 2016 · 17 comments

Comments

@hhrutter
Copy link

Visual Studio Code 1.7.2
Go Extension 0.6.51
MacOS: Sierra 10.12.1

After a couple of minutes into an editing session of go code I get at least one godoc process taking up lots of cpu. Killing these processes is a work around - still annoying.

@ramya-rao-a
Copy link
Contributor

Did you recently upgrade to Mac OS X Sierra?

There is a known issue of performance on Mac OS X Sierra. See #503

Run the command Go: Install Tools. That should update all the go tools that the extension depends on which should fix the issue

@hhrutter
Copy link
Author

I already did that. I still get godoc processes running wild.

@ramya-rao-a
Copy link
Contributor

Is it project specific? Does it happen on smaller packages as well?

@dvdplm
Copy link

dvdplm commented Dec 30, 2016

I am seeing this too but chalked it up to using Insiders builds and go 1.8beta1. I am also on macOS Sierra. AFAICT it is not project specific and happens on smaller projects as well. Killing the godocs process "fixes" the problem but it returns when I leave the code editor idle for a while.

@ramya-rao-a
Copy link
Contributor

@dvdplm Did running the command Go: Install Tools help as described in #503 ?

@ramya-rao-a
Copy link
Contributor

@hhrutter @dvdplm Any updates?
Can you also try switching to use gogetdoc and see how that behaves?
Set "go.docsTool": "gogetdoc" in your setting

@dvdplm
Copy link

dvdplm commented Jan 3, 2017

@ramya-rao-a I did re-install the tools but still had the problem. Yesterday I had a full day of coding and it never happened. I updated to latest Insiders build yesterday morning though so I was hoping that a fix snuck in!

@ramya-rao-a
Copy link
Contributor

Thanks @dvdplm
@hhrutter How about you?

@zmb3
Copy link
Contributor

zmb3 commented Jan 4, 2017

@ramya-rao-a I think the hover provider is a bit too liberal in spawning go doc / gogetdoc processes, which explains this and probably also #698 and #667.

A few suggestions:

  • try to limit the number of calls to definitionLocation() (maybe by increasing the hover timeout)
  • break out early (prior to spawning a doc process) if it looks like there's nothing interesting under the cursor (i've seen the extension call gogetdoc when the cursor is over whitespace - this is inefficient) Can we look at the word under the cursor and only query for doc if it appears to be a valid Go identifier?
  • don't launch more than one doc process simultaneously. keep track of the currently running doc task, and if a new call to definitionLocation() is made before the previous task finishes, assume the user moved the mouse and are no longer interested in the original call.

I suspect the last one will have the most impact. The doc processes do consume a lot of CPU, which is fine if they only run for < 1s. However if we allow 4-5 of these processes to run simultaneously as the user moves the mouse around the editor we'll surely be impacting performance.

@dvdplm
Copy link

dvdplm commented Jan 5, 2017

@ramya-rao-a This just happened again, same pattern: out of the blue the fans go nuts and when I go look it's a godoc process running wild. It does not stop by itself. I will try using gogetdocs now.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jan 5, 2017

@zmb3 I can get started with your second suggestion. I am checking with the vscode team if there is way for the extension to know if the cursor is over a valid identifier based on the language grammar.
If not, then for now, I can whitelist the below cases and return null instead of calling godef+godoc or gogetdoc

  • Not a word
  • Is a keyword
  • Is a number
  • Is part of a string literal
  • Is part of single line comment

#711

@ramya-rao-a
Copy link
Contributor

#711 is merged.

@dvdplm Can you update to the latest VS Code and the latest Go extension (0.6.52), and let us know if things are better?

We will continue to work on this.

@dvdplm
Copy link

dvdplm commented Jan 6, 2017

@ramya-rao-a updated, will keep watching for strangeness, thanks!

@hhrutter
Copy link
Author

hhrutter commented Feb 9, 2017

  • VSCode Version: Code 1.9.1 (f9d0c687ff2ea7aabd85fb9a43129117c0ecf519, 2017-02-08T23:31:51.320Z)
  • OS Version: Darwin x64 16.4.0
  • Extensions:
Extension Author Version
Go lukehoban 0.6.53

This latest environment still has the issue of godoc processes clogging the CPU.
But.. gogetdocs did the trick for me!

I suggest "go.docsTool": "gogetdoc" as default value.

Thanks :)

@ramya-rao-a
Copy link
Contributor

The latest update of the Go extension (0.6.54) has the integration with the language server available via a setting go.useLanguageServer

The features powered by the language server are Hover, Definition, Find All References, Signature Help, Go to Symbol in File and Workspace.

Give that a try and let us know if you see improvements in the performance

@legendtkl
Copy link

go.useLanguageServer works.

@ramya-rao-a
Copy link
Contributor

It's been over a year since the original issue was logged and there has been many changes in the extension since then that has improved perf.

Locking and closing this issue for now.

If anyone sees any perf issues, please log a new issue

@microsoft microsoft locked as resolved and limited conversation to collaborators Jan 8, 2018
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

5 participants