Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion is instantaneous, but go to definition is very slow #236

Open
64kramsystem opened this issue Nov 25, 2021 · 2 comments
Open

Comments

@64kramsystem
Copy link

64kramsystem commented Nov 25, 2021

Hello,

I'm working on a relatively small project (8k Ruby lines, according to cloc v1.90; only a few dependent gems). I've documented all the methods in the project (the vast majority with @return [void], and some with actual param/return types).

With this setup, autocompletion is essentially immediate. It fully works as intended: the plugin is aware of the given instance type, and shows the accessible methods list (in turn, each method shows a window with the reference to the class+method, and the method documentation).

The problem is that the "Go to defiition", for the very same instance, is instead very slow; it generally uses 100% of the CPU for several seconds each time, making it unsuitable for usage on a laptop, besides making it hardly usable in general.

Something I've also observed is that the time taken is actually - sometimes it jumps immediately, but after jumping to a few other methods, even if nothing in the project changed, it takes again a long time. It behaves like there was a sort of "hot methods cache" that is busted after going to a few method definitions.

Is such slowness expected? It's counterintuitive to me - without knowing the internals - that autocompletion shows complete (metadata) knowledge of a given method, but actually jumping to the method is extremely slow in comparison.

===

Regarding the configuration:

  • VSC 1.62.3
  • Ruby: 3.0.2
  • Solargraph: 0.44.2
  • Ruby Solargraph plugin: v0.23.0
@64kramsystem
Copy link
Author

64kramsystem commented Nov 25, 2021

I've found the overall behavior to be odd; it seems Solargraph (and/or the VSC plugin) gets "clogged" when "Go to definition" is issued. I'll describe a couple of examples.

Base code (extreme simplification of the original):

class Runtime
  # @param location [TemporaryVariable, Fisk::Operand, Integer]
  # @return [void]
  def jump(location)
    # blah
  end

  # @return [Fisk::Operand]
  def return_value
    # blah
  end
end

rt = Runtime.new
rt.jump rt.return_value

First case:

  • I move the cursor at then end
  • I type rt. at the end -> I get immediately the autocompletion list, including the jump method
  • I follow up and type jump (after the rt.), then tap F12 -> VSC goes to definition immediately
  • I go back to the code above, and tap F12 on the first rt.jump -> VSC thinks for many seconds
  • I now go back to the second rt.jump and tap F12 -> VSC takes a long time

Second case:

  • I restart the VSC server, and move the cursor at then end
  • I type rt.jump(123)
  • Move the cursor to jump (before the parenthesis) and tap F12 -> it takes more time
  • Again, if I now go back to the second rt.jump (without param) and tap F12 -> VSC takes a long time

Is there any way to debug vscode-solargraph and/or solargraph, to profile how the time is spent?

@castwide
Copy link
Owner

castwide commented Dec 5, 2021

I looked into this, and the the "go to defintion" request definitely seems slower than it should be. I'll keep this on the radar and look for a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants