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

Autocomplete/suggestions take 9s+ [0.31] #99

Closed
greggilbert opened this issue Jan 18, 2019 · 16 comments
Closed

Autocomplete/suggestions take 9s+ [0.31] #99

greggilbert opened this issue Jan 18, 2019 · 16 comments

Comments

@greggilbert
Copy link

I think this has been an issue for me for awhile, but I've noticed it more and more.

Basically, suggestions consistently take around 9 seconds. I've tried Stri(Ctrl+C), String.new.(Ctrl+C), Enum(Ctrl+C), and it's always the same. Developer Tools doesn't show any errors. I've got a .solargraph.yml which excludes .git and a number of other folders.

These are the only changes in my settings.json:

    "ruby.interpreter.commandPath": "/Users/Greg/.rvm/rubies/ruby-2.5.1/bin/ruby",
    "solargraph.commandPath": "/Users/Greg/.rvm/gems/ruby-2.5.1/bin/solargraph",

Seems like it's good for everyone else, so I'm not sure what's going on. Any ideas?

@castwide
Copy link
Owner

How large is your workspace? E.g., number of files, total lines of code, and included gems

How big is the file you're editing? In my experience, performance can degrade with files above ~2000 lines.

Is the workspace on a local drive or a network share?

You can also try to setting solargraph.logLevel to info for more information about what it's doing.

@greggilbert
Copy link
Author

I've got 15 folders in my workspace, but only three of them are Ruby. The Ruby ones are, I'd say, total less than 10k LOC. Number of gems in each varies, but the Gemfiles are average 125 lines long?

The workspace is a local drive (SSD).

"performance can degrade with files above ~2000 lines." - does that mean that one file with 2k lines will cause issues?

@castwide
Copy link
Owner

I've got 15 folders in my workspace, but only three of them are Ruby. The Ruby ones are, I'd say, total less than 10k LOC. Number of gems in each varies, but the Gemfiles are average 125 lines long?

That doesn't sound big enough to cause so much lag. It might have a significant impact on initialization time, but not so much in completion suggestions.

"performance can degrade with files above ~2000 lines." - does that mean that one file with 2k lines will cause issues?

Yes, specifically if it's the one you're currently editing. The workspace as a whole should be able to handle tens of thousands of lines.

@greggilbert
Copy link
Author

The file I'm using is 24 lines long and just has one class in it.

I turned on logging to debug, and it looks like it's indexing multiple times. Every time I type another letter, it reruns everything: Indexing workspace files in /PATH. Is it supposed to do that?

@castwide
Copy link
Owner

No, that's definitely unusual. Cataloging is a frequent operation, but indexing the workspace shouldn't happen every time you type. It usually happens when a workspace file gets created or renamed. Do you also see a lot of messages for workspace/didChangeWatchedFiles?

Are you using the most current versions of the extension (0.19.1) and the gem (0.31.1)?

@greggilbert
Copy link
Author

greggilbert commented Jan 23, 2019

Every time I type, I get a dumpout in the console that looks roughly like this. I see console.ts:134 [Extension Host] [INFO] Server received textDocument/didChange repeatedly.

And yeah, this is using the latest extension and gem.

I just tried disabling all of my current extensions and left this one on, and it still happens.

@castwide
Copy link
Owner

The textDocument/didChange messages are normal. The Indexing workspace files messages shouldn't happen anywhere near that often, especially for a change to a file that's already open.

Are you working in a multi-root workspace?

@YoannNovaxis
Copy link

I got the same problem, loading time was very long for suggestions and autocomplete. I just deleted the .solargraph.yml file and it worked...

@castwide
Copy link
Owner

@YoannNovaxis Thanks for the tip. Can you tell me if you still have the problem when you generate a default .solargraph.yml file? It should result in the same configuration you'd get without a file.

@YoannNovaxis
Copy link

@castwide I did not have the problem after generating default .solargraph.yml file.

When I had the problem the file looked like

include:
  - ./**/*.rb
exclude:
  - spec/**/*

The default file with command solargraph config look like

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
plugins: []
require_paths: []
max_files: 5000

It seems that some options correct the problem.

@castwide
Copy link
Owner

My guess, the additional exclude rules fixed it, especially if Solargraph was trying to map files for cached gems.

@greggilbert
Copy link
Author

@castwide: Yes, it's multi-root. When I said there were 15 folders, I meant each of those is a separate root. An edit in any file causes them all to reindex?

@castwide
Copy link
Owner

Yep, that's the problem. It appears to be specific to multi-root. Editing a file should not require a reindex of any of the folders, including the one that contains the file.

I should be able to work a fix into the next patch release.

@greggilbert
Copy link
Author

Awesome, looking forward to it. Let me know when it's in and I'll test.

@castwide
Copy link
Owner

The fix is published in gem v0.31.2.

@greggilbert
Copy link
Author

@castwide It's much, much better now. And I can confirm that I'm not seeing constant reindexing. Thanks!

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

3 participants