emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
617 stars 162 forks source link

Occasional character input lag on Windows 10 #840

Open jthaman opened 5 years ago

jthaman commented 5 years ago

Hi, I'm using ESS 18.10 on a Windows 10 computer with Emacs 26.1 . I'm finding that there can be significant character input lag while entering information into a function.

Here is a minimal init.el that I tried using.

(setq exec-path(append
                '(
                  "C:/Program Files/R/R-3.5.2/bin"
                  "C:/Program Files/R/R-3.5.2/bin/x64"
                  )))

(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives
      '(("gnu" . "https://elpa.gnu.org/packages/")
        ("melpa-stable" . "https://stable.melpa.org/packages/")
        ("org" . "https://orgmode.org/elpa/")
        ("melpa" . "https://melpa.org/packages/")))
(package-initialize)
(unless package-archive-contents
  (package-refresh-contents))
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(setq use-package-verbose t)

;; my packages
(use-package ess
  :pin melpa-stable
  :config
  (defun my-ess-settings ()
    (setq ess-indent-with-fancy-comments nil))
  (add-hook 'ess-mode-hook #'my-ess-settings)
  (setq ess-R-font-lock-keywords
        (quote
         ((ess-R-fl-keyword:keywords . t)
          (ess-R-fl-keyword:constants . t)
          (ess-R-fl-keyword:modifiers . t)
          (ess-R-fl-keyword:fun-defs . t)
          (ess-R-fl-keyword:assign-ops . t)
          (ess-R-fl-keyword:%op% . t)
          (ess-fl-keyword:fun-calls . t)
          (ess-fl-keyword:numbers . t)
          (ess-fl-keyword:operators)
          (ess-fl-keyword:delimiters)
          (ess-fl-keyword:=)
          (ess-R-fl-keyword:F&T))))
  (setq ess-ask-for-ess-directory nil)
  (setq ess-smart-S-assign-key nil))

Now if I start an R process and start typing code

x <- c(

I observe lag while I'm entering the remaining characters on the line. It seems like ESS is looking for something to complete once I open a "(" ? Is there a way to turn it off? The input lag can be quite large, and my Windows 10 computer is pretty high-end.

The lag seems to only occur the first time I try to type x <- c(. Subsequent lines that are identical can be typed without perceptible lag.

Thanks for any help, and for working on ESS in general.

jthaman commented 5 years ago

I think I have same problem as the person who wrote this StackExchange post https://emacs.stackexchange.com/questions/9621/how-to-find-what-causes-ess-to-run-very-slow

jabranham commented 5 years ago

Have you tried disabling eldoc-mode, company-mode, and flymake-mode?

If so, perhaps see if it's the built-in completion by navigating to an R buffer where this problem exists and doing M-: (setq completion-at-point-functions nil)

vspinu commented 5 years ago

There have been several fixes in the master branch after 18.10. The caching wasn't working quite as expected. Would be great if you could try the development (or melpa) version and try again.

jthaman commented 5 years ago

I've updated to the latest Melpa version, 20180217, and tried fiddling with the modes suggested by @jabranham. It seems that eldoc-mode may be the culprit: I don't use company mode, and it doesn't seem like disabling fly-make has an effect on the input lag. Disabling eldoc-mode removes any input lag I experience in ESS using my regular init.el. Changing eldoc-idle-delay to different values changes when the character input lag occurs once an open paren is typed.

I personally find eldoc tips in the minibuffer to be sometimes useful, so I would like to have this mode enabled while working in ESS. I wonder if there is a way to use eldoc-mode asynchronously?

jabranham commented 5 years ago

@jthaman thanks for reporting back. Eldoc will need to be refactored before our next release anyway to deal with changes upstream (see #794) so we'll tackle these at the same time I guess.

jthaman commented 4 years ago

Just curious if there are any updates on this issue, or anything I can do to assist. Is it possible that this "ESS stalls and flashed no process" bug is related to the Windows 10 file system?