When working with an iESS session of R and an R file open side-by-side, I noticed extremely slow performance when typing indetifiers. Typing braces and operators is fine, however, when an identifier is typed, there is very significant input lag (typed letters are appearing several second late). During this period, the the status of the iESS buffer flashes between
no process. This happens most often when I am typing inside a function argument list and with a subordinate R process that consumes a sizeable chunk of memory (around 3G, a couple of big data frames and sparse matrices).
I have disabled
company-mode, but ESS still seems to do something to the background R process synchronously.
What causes this? How can I profile ESS to find out how it spends time communicating with R?
profiler-start and its friends, which show that Emacs spends 45% of its time in
term-emulate-terminal (I ran
htop in an ansi-term buffer to see the CPU usage of emacs and R) and 16% in the Automatic GC. That's hardly suspicious. I guess the time spent waiting for the subordinate process is considered idle time by the profiler.
emacs -qthen evaluate just those part of your init file that sets up ESS. If the behavior is observed there I would file a bug report. If not, keep loading sections of your init file until you find the part responsible for your problem. Also, you may want to state which versions of Emacs and ESS you are running.
M-x load-library RET term.el RET(i.e. load the uncompiled version of term.el) and then redo the profiling: it might give you a more detailed profile.