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
Freezes on argument completion with the R backend for company-mode #1062
Comments
This is likely related to the issue I've been having recently, where I call the help function on anything (e.g. |
@japhir The fix should be on MELPA soon. Can you let me know if it works for you please? |
Though it does sound like that's a different issue. The full error message would be helpful. |
Ok thanks for getting back to me so quickly, I created a separate issue in #1075 |
@lionel- maybe there is a way to optimize Agreed on disabling meta (the variable is now called |
I can consistently reproduce the following freeze:
print(i = )
The freeze time seems to be influenced by the number of package loaded. Loading tidyverse and devtools results in much longer freezes.
Finding out what causes the freeze
Since debugging this sort of performance issues is not trivial, I'll document here how I found out the cause of the slowdown as this might be useful to users or developers. First I instrumented all ESS functions with the Emacs tracer:
Ignoring all the irrelevant parts (such as ESS timers running periodically), I found the freeze likely occurred during
ess-r-get-arg-help-string
. More specifically, this part:(ess-command ".ess_arg_help('intercept','print')\n")
It turns out that the freeze occurs at R level:
Profiling suggests that a lot of time is spent in
readRDS()
viahelp()
.Fixing the freeze
ess-r-get-arg-help-string
is called by themeta
method of the company-mode backend for R (implemented iness-r-completion.el::company-R-args
). The result of this function is displayed in the echo area when an argument is highlighted.A few thoughts:
Personally I had never noticed that these help strings were displayed in the echo area on completion. Probably because my eyes are focused on the drop-down menu that displays the completions. Since that feature is a "nice-to-have", and not very discoverable, I guess we can consider it non-critical.
Caching would not really help, at least not for generics since available methods depend on the state of the session. Also the first access would still cause freezes.
To implement this sort of contextual help with information stored on disk, synchronous requests are not appropriate. For this sort of things we need asynchronous routines. Unfortunately we don't have the tooling for this.
Since the contextual help is not critical nor discoverable, and since implementing correctly seems to be very difficult, I would suggest just removing the
meta
method from the company backend.I have added an escape hatch until we sort this out: 44c0ddb71. Add
(setq ess-r--no-company-meta t)
to your init file to disable the feature causing the freezes.The text was updated successfully, but these errors were encountered: