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

Code Lens issues #977

Closed
hungys opened this issue May 8, 2017 · 9 comments
Closed

Code Lens issues #977

hungys opened this issue May 8, 2017 · 9 comments

Comments

@hungys
Copy link

hungys commented May 8, 2017

I really appreciated that Code Lens finally arrived for Golang, but after trying for it, I found that there are many issues.

  1. Performance
    When using it in a "not so big" project, it always takes more than 5 seconds to calculate the reference counts.

  1. Incorrect reference count on function
    Sometimes it just shows 0 reference, but that's not the fact. This cannot be reproduced every time.

(Related issue: sometimes function declaration itself is counted as 1 reference in Find All Reference?)

  1. Not supported for method?
    For methods (member functions), it always shows 0 reference. Doesn't Code Lens support for member functions?

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @hungys

Performance

Are you on 0.6.60 or 0.6.61? There was a perf issue we found in 0.6.60 which we fixed in 0.6.61. The issue was that the cache for references in codelens was being invalidated every time and so every scroll would re-calculate references again

How is the performance when you run "Find all references" from the context menu? We use guru to get references and have seen it being slow for Windows users

0 showing up

I'd love to get a repro of this. Current running theory is that for some reason finding references fails in which case 0 is the default value shown. May be I can change it to "Couldn't find references" so that it is differentiated from the real case of 0 references.

Method support

#962 is tracking this one and we will have support for this in the next update

@hungys
Copy link
Author

hungys commented May 8, 2017

@ramya-rao-a

Performance

I'm on VS Code 1.12.1 with Go extension 0.6.61. (macOS 10.12.4)

For the Code Lens, will the cache be invalidated when re-opening or switching between different files? But the fact is that every time I open a file (75 LoC, and the whole project contains ~2000 LoC), it takes about 5 seconds to let the reference count show up.

For "Find all references", it is also a little bit slow on my project, and I think it's also not cached?

0 showing up

I cannot reproduce it today, but I think it's a good idea to differentiate these two cases :)

Method support

Oh sorry, I didn't notice that.

PS. The repo I tested with: https://github.com/hungys/swimring

@ramya-rao-a
Copy link
Contributor

The cache is invalidated when there is a change in document or when you switch documents. Its how the VS Code Api works. The first case makes sense, but the second doesn't.

"Find all references" in itself is never cached. If that itself is slow, then am afraid, there is nothing much we can do for the codelens.

Unless of course there is a better solution to find references other than using guru.

@ramya-rao-a
Copy link
Contributor

@hungys The method support has been out since a month.

Were you able to repro the 0 references issue?

If there is nothing else to do here, then can we close the issue?

@hungys
Copy link
Author

hungys commented Aug 2, 2017

@ramya-rao-a

0 reference issue still occurs randomly.

I've checked that the method support just works, but sometimes it also report 0 reference (which is incorrect).

BTW, is it possible to calculate all the reference counts at once, but not wait until we scroll to them?

@ghost
Copy link

ghost commented Nov 16, 2017

Yeah they dont use this now.
Instead they use SourceGraphs golang language server and it works much better.

https://github.com/Microsoft/vscode-go#go-language-server-experimental

go get -v github.com/sourcegraph/go-langserver

Settings..
//-------- Golang configuration --------
"go.buildOnSave": "workspace",
"go.lintOnSave": "workspace",
"go.vetOnSave": "workspace",
// This is the new souregraph based language server. Its recommended to use this (https://github.com/Microsoft/vscode-go)
"go.useLanguageServer": true,
//"go.formatTool": "goreturns",
"go.gocodeAutoBuild": false,
// "files.autoSave": "onFocusChange",

@ramya-rao-a
Copy link
Contributor

@gedw99 The use of language server is optional, we still support the previous way of doing things. Also the codelens for references doesnt use the language server.

@hungys

BTW, is it possible to calculate all the reference counts at once, but not wait until we scroll to them

Yes, that's possible. But finding references is expensive. If all references count were found upfront, then it would take a while for them to appear.
The real solution would be either for the language server to support the codelens or for us to find faster way to get references.

About the 0 references when there are references, what's happening is that guru is failing to find the references. Instead of showing error, the current codelens shows "0 references"

In the next update, instead of 0 references, the codelens will say Error finding references and the error would be displayed in the console.
So hopefully we will have more to go on in finding the root cause behind the guru failures

@JanKoehnlein
Copy link
Contributor

I found a repro for the Error finding references.

  • Check out go itself from https://github.com/golang/go
  • enable reference codelens in the settings
  • open src/compress/bzip2/bit_reader.go
    -> Error finding references on the last 4 functions in the file.

guru is called as

~/go/bin/guru referrers -modified go/src/compress/bzip2/bit_reader.go:#1038

and reports

guru: query object not found during reloading

@ramya-rao-a
Copy link
Contributor

With the ongoing work on the language server, there will be less work on getting guru to work better.

With this in mind, I am closing this issue as there is no actionable item from the extenion's side at the moment. Once the language server has the references feature, we will enable the codelens from it instead of calling guru.

Thanks for your patience and Happy Coding!

@microsoft microsoft locked as resolved and limited conversation to collaborators Jul 7, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants