Skip to content
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

High usage of CPU when emacs is idle #43

Closed
xbelanch opened this issue Apr 20, 2020 · 8 comments
Closed

High usage of CPU when emacs is idle #43

xbelanch opened this issue Apr 20, 2020 · 8 comments

Comments

@xbelanch
Copy link

See the reddit thread: https://www.reddit.com/r/emacs/comments/g4ojo9/emacs_freezes_on_windows_10/

@ChillarAnand
Copy link
Owner

@xbelanch Thanks for reporting the issue.

I am not sure why it is adding load on CPU. Will check on a windows machine.

@xbelanch
Copy link
Author

xbelanch commented Apr 20, 2020

@ChillarAnand check out the last init.el I have before I need to comment the real-auto-save package reference if it helps: https://github.com/xbelanch/personal-emacs-dot-files/tree/development

@guseggert
Copy link

I'm also experiencing this on a Mac. I think it's related to this commit: ffef949

When I (setq real-auto-save-use-idle-timer nil) the issue goes away.

Profiler output:

- timer-event-handler                                            7054  81%
 - apply                                                         6654  77%
  - real-auto-save-buffers                                       3164  36%
   - real-auto-save-restart-timer                                2416  27%
    - real-auto-save-start-timer                                 1827  21%
     - run-with-idle-timer                                       1698  19%
      - timer-activate-when-idle                                  792   9%
       - timer--activate                                          607   7%
          timer--time-less-p                                      459   5%
          timerp                                                   13   0%
      - timer-set-idle-time                                       423   4%
         seconds-to-time                                          129   1%
       - timer--time-setter                                        47   0%
          timerp                                                   21   0%
      - timer-set-function                                         59   0%
         timerp                                                    24   0%
    - cancel-timer                                                167   1%
       timerp                                                      39   0%

@conao3
Copy link
Collaborator

conao3 commented Apr 28, 2020

After #42 change, all my CPU is fully occupied by Emacs.
Are you have any suggestions?
Is it working well in your environment?

Run Emacs using below debug init.el and open ~/.debug.emacs.d/real-auto-save/init.el, Emacs use 100% of one CPU.

init.el

;; ~/.debug.emacs.d/real-auto-save/init.el

;; you can run like 'emacs -q -l ~/.debug.emacs.d/{{pkg}}/init.el'
(when load-file-name
  (setq user-emacs-directory
        (expand-file-name (file-name-directory load-file-name))))

(prog1 "prepare leaf"
  (prog1 "package"
    (custom-set-variables
     '(package-archives '(("org"   . "https://orgmode.org/elpa/")
                          ("melpa" . "https://melpa.org/packages/")
                          ("gnu"   . "https://elpa.gnu.org/packages/"))))
    (package-initialize))

  (prog1 "leaf"
    (unless (package-installed-p 'leaf)
      (package-refresh-contents)
      (package-install 'leaf))))

(leaf real-auto-save
  :ensure t
  :hook (find-file-hook)
  :config
  (real-auto-save-activate-advice))

Screenshots

Screenshot_2020-04-29_02-26-48
Screenshot_2020-04-29_02-26-31

Environment:

$ uname -a
Linux conao-manjaro-helios 5.4.35-1-MANJARO #1 SMP PREEMPT Thu Apr 23 10:54:43 UTC 2020 x86_64 GNU/Linux
conao-manjaro-helios:~/dev/repos/leaf-keywords.el conao


$ emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

@novoid
Copy link

novoid commented Apr 28, 2020

I can confirm this issue with:

  • elpa/real-auto-save-20200418.405
  • emacs-version 26.3 on (X)Ubuntu 20.04 LTS
  • emacs-version 26.1 on Debian stable 10 Buster

My configuration:

(use-package real-auto-save
  :ensure t
  :after org
  :config
  (add-hook 'org-mode-hook 'real-auto-save-mode)
  (setq real-auto-save-use-idle-timer t)
  (setq real-auto-save-interval 60)
  (real-auto-save-activate-advice)
)

After real-auto-save-interval of emacs idle time (not system idle time), one CPU core starts working on the emacs process. Switching back to emacs does kill this CPU usage pattern. Again, after real-auto-save-interval of emacs idle time, one CPU core starts working again.

When I use (setq real-auto-save-use-idle-timer nil) this does not happen. When I don't open an Org mode file, this does not happen (most likely because :after org and (add-hook 'org-mode-hook 'real-auto-save-mode)).

@ChillarAnand
Copy link
Owner

Thanks, @conao3 for the fix.

This issue is fixed in the latest version.

@novoid
Copy link

novoid commented Apr 29, 2020

I can confirm that this fix resolves the issue at my side.

@ChillarAnand
Copy link
Owner

Thanks, @novoid

Closing this issue. If anyone is still facing this issue with latest version, please re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants