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
Solargraph suggestions are slow on large files #95
Comments
I've noticed a similar issue on large files. In my tests, the difference starts to be measurable around 600-700 lines and increases from there. It's typically not a problem if it's a background file in the workspace; only while the file is being changed. The major issue appears to be the mapping process. In your debug log, the start of that process is marked by the There are two possible improvements I'm trying:
|
Both options sounds promising. Perhaps you should go with one that "faster to implement". P.S: Oh, It's killing me 😭. May I kindly ask that you prioritize this -more-? |
Asynchronous cataloging looks like a very good candidate for inclusion in v0.31.0, which I hope to have ready by next week. I'll keep you updated. |
It looks like asynchronous cataloging helps. The mechanism was already there in the form of a cataloger that runs in its own thread. The problem was that certain queries would make unnecessary cataloging requests, resulting in the main thread waiting for the cataloger thread to finish its current operation. Completion item requests, in particular, should be able to query the map in its current state while the cataloger updates it in the background. My tests look good so far. The gem v0.31.0 branch returns completion items about 10-20 times faster on average. You're still liable to see some slowdown in files with 1000+ lines of code, but hopefully not the 4-5 second lag you've been seeing in |
@castwide, I've tested that branch, however, i see almost same response times as the previous one. In this branch, Here is |
I just pushed a change that might affect this issue, albeit slightly. It removes a thread pooling process that turned out to be ineffective when I benchmarked it. Do you get the same lag with subsequent calls? Example:
I also noticed in your output that the most recent cataloging process always finishes between the |
Okay, it looks like the problem is somewhere else. This part of the log seems to indicate that asynchronous cataloging works: Cataloging got scheduled by Is Can you give me a rough estimate of how big your project is? Especially number of files and installed gems. |
Local drive. In fact both
There are 301 Additional update: There are 589 folders (gems) in my gems folder in Ruby lib dir. |
@castwide, 2 questions:
|
Another thing you can try: opening the project without gems. The easiest way should be to temporarily rename |
I will try without a gemfile as you suggested and report back. |
I pushed a fix for those rogue processes you saw. It was an unrelated bug in how v0.31.0 handles notifications between the language server and the transport. The transport didn't know the server stopped, so it just kept listening to the socket. Thanks for catching it. |
I'm glad I could help on this. |
I did some development and troubleshooting using the project you sent me. First, I was a little surprised at how long it took to initialize your workspace. Average was about 105 seconds, even though your project only has 13,633 pins (a pin is a mapped location in code, such as a method definition or a variable assignment). For comparison, I have a project with 12,221 pins that loads in under 6 seconds. Solargraph has 43,253 pins and loads in 20 seconds. It turns out that one of the bottlenecks is large comment blocks. If I exclude the As for slow completion suggestions, I’ve found a significant cause and a possible solution. When the code contains an incomplete statement like My solution is to separate file updates into two parts. First, the server notifies the map that the code has changed, but doesn’t try to update the map itself. That way the completion request knows what code snippet you’re trying to complete and can query it against the map that’s already in place. Second, both parsing and cataloging run asynchronously in the background so they don’t block other queries. Testing with your project, completion for This update is liable to be too major to make it into gem v0.31.0, so I’ve started a new branch |
I've tested that branch and yes, it just worked as expected. Instantly get complete results for For the startup delay: I was thought it is slow because i have more gems. It will be better if you can do a workaround for those comment blocks. Thank you so much for making Solargraph faster. |
I pushed another change to |
Perfect. Tested now. One of my project was taking 2-3 minutes to start now it tooks 1 min 10 seconds. Definitely better than before. In my case I think Thank you once again, Fred. You made my environment and development better than ever! |
Thanks, glad to hear it! I'll keep load time improvements on the radar, but any further enhancements will probably be non-trivial. The new specs on the |
The changes are published in gem v0.31.0. |
Fred, if you got my previous message, please discard it. It was probably a cache that bundler made. So it was slow because it was using older Gem is awesome. Thanks. |
Removed deprecated Library methods Tweaked foldable comment ranges Host::Dispatch module for managing open sources and libraries YardMap::CoreGen module for generating documentation from Ruby source Improved communication between hosts and adapters Refactored Host methods `@!domain` directive uses [type] syntax Make SourceMap#query_symbols use fuzzy matching. (#132) Threaded ApiMap cataloging Fixed fencepost error in Position.from_offset Lazy method alias resolution Library#references_from returns unique locations Additional info logs Asynchronous source parsing Unsychronized source support for faster completion requests (castwide/vscode-solargraph#95) Faster source comment parsing Host only diagnoses synchronized sources
I have two files in this example:
File 1: container.rb
File 2. file.rb
container.rb
contains almost 1.700 lines of code andfile.rb
has around 150. When I work on large file likecontainer.rb
suggestions are very slow to respond. See here:However, on same project if I open
file.rb
and write there, suggestions are very fast. See:I tried
Socket
andstdio
as transport. Neither helped.You can also see output of solargraph i recorded them too.
The text was updated successfully, but these errors were encountered: