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
Pry *rails* buffer company not stopping completion after dot #96
Comments
You aren't really supposed to use The What does |
@sandric Ping? |
@dgutov Yes, here's my output:
and long long list lasts forever. |
So if I understand you correctly, the complaint is that completion takes a lot of time, pegs CPU to 100%, and doesn't take dots into account. The last one is a consequence of what completion code in e.g. Now, to clarify, does this also happen in any project that uses Pry, no matter how small? Or it that only a problem with certain projects you have at work? |
If the answer to my last question is yes, try evaluating this in one such project: class Module
alias_method :__name__, :name
end
ObjectSpace.each_object(Module).select { |m| m.__name__.nil? }.count I have a project like that at work, and the return value here is 15000+. Which is a problem because UPDATE: Or not. Simply having this many anonymous modules doesn't cause the delay. Investigating. |
You can follow pry/pry#1540 and pry/pry#1588. |
@sandric inf-ruby completion should finally be fast with pry 0.11.0. Could you test? |
@dgutov sorry for not reaching out before. Using 0.11.3 and being on much slower computer I can see this behavior only on very big datasets - such as common object, like Integer, followed by dot. Active Record models on other side is working beautifully, so I think issue can be closed already. But if there's a way to somehow limit autocompletion to all classes but basic, because they have very big autocompletions amount, it would be perfect in my case. Or other way around that still can work for those cases - add setting like |
Hmm. Do you mean to say that Integer has more methods than ActiveRecord::Base? And by a lot?
Yeah, it aims to provide that "completion after dot" behavior, since it often works okay. Not so in |
@dgutov Oh, no, not integer, sorry. I'm not sure what class that actually is, I can reproduce that by inserting dot after ActiveRecord instance that is got via chaining. So, for example, if you have AR model User, inserting this |
In any case, is there any possible way to somehow make |
Ah, so it's the exact case I've worked on speeding up: "we don't know what type it is, so let's show all methods from all classes". 😞 Does completion work for you at all in such cases, in terminal Pry?
Yes, totally possible. I'd like to investigate the above problem first, though. |
In terminal pry I see almost no latch, like half a second maybe. |
OK, but there are a lot of completions there? How many does it say? |
@dgutov 10694 in my case. |
@dgutov and completions for the same completion but on previously instantieted variable is about 100. |
Which is quite a reduction)) |
Yup: Pry doesn't evaluate the intermediate steps of the chain (for safety, they might have side-effects). |
Yes, but where does that number coming from anyway? I mean |
From ObjectSpace.each_object(Module){|m|
next if (to_ignore.include?(m) rescue true)
# jruby doesn't always provide #instance_methods() on each
# object.
if m.respond_to?(:instance_methods)
candidates.merge m.instance_methods(false).collect(&:to_s)
end
} :) |
Anyway, let me see where the bottleneck in inf-ruby can be. Maybe just Emacs's slow processing of output. Then a user option is the obvious way to go. |
ok. Thanks a lot for all your effort by the way!) |
Spanning from the last dot, not from the beginning of expression. To work better with company-minimum-prefix-length, dgutov/robe#96 (comment).
Done. This removes automatic completion after dot, though. I'll look into re-adding a smarter version of it. |
Cool. But for me the problem now moved from delay after inserting point to delay after third character. Sorry... |
Are you sure you're using the new Pry there? I've tried it in a work project, the number of methods is ~30000 (right after dot), and the completion after 3 characters is pretty much instantaneous. Completion right after dot takes ~1 second. Does that happen only for some specific prefixes, maybe? |
Oh, I wrong again, I missed out that for some reason I got not
If I enter group :development do
#...
gem 'pry'
gem 'pry-doc'
gem 'pry-byebug'
end |
That makes sense: I haven't submitted the performance improvements to IRB yet.
After a dot and three characters? That still sounds too long, but there's not much else I can do here without extra investigation on your part. Let me know if you find where the bottleneck is.
That's easy: robe-start calls |
If I run
robe-mode
in .rb file everything works fine, but in*rails*
buffer with pry running because of autocompletion everything works very long. The problem is as I understand is that in.rb
files if you chain methods via dots, every time it meets that separator - robe stops autocompletion.My settings
(setq company-minimum-prefix-length 3)
, so in files everything works smoothly, but looks like that parameter works only for line starting in*rails*
but not understanding dots. I don't know if thatsinf-ruby
issue, but looks like that appears only in buffer created viarobe-start
.Update: I just tried to enable via
M-x
robe-mode
in pry rails buffer and now looks like it works as needed! Is it my fault and that buffer should have enabledrobe-mode
?The text was updated successfully, but these errors were encountered: