5

Is there some way to find out, what in Emacs is causing spurious cpu usage?

Since a few days I notice Emacs retaining high CPU usage despite not being used actively, having no subprocesses, and not being in blocking state. M-: (all-threads) is empty, except for (current-thread). I also wasn't able to reproduce the issue across sessions.

I am using Emacs on Windows 10, so many unix tools will not be applicable.

7
  • 1
    Setting debug-on-quit and hitting C-g when Emacs is maxing CPU might give a hint.
    – npostavs
    Feb 27 '19 at 3:06
  • @npostavs – Sadly no. Whatever is using the CPU is doing it in a non-blocking manner. No hickups, that would indicate a time-window for pressing <kbd>C-g</kbd>. The only reason I noticed, was because the fan was spinning more than usual.
    – kdb
    Feb 27 '19 at 16:38
  • You can keep an eye on the Task Manager tray icon which would show when CPU usage is up.
    – npostavs
    Feb 27 '19 at 16:54
  • @npostavs I have encountered the issue again today. toggle-debug-on-quit and C-g don't trigger the debugger. And since the CPU usage has incrased, it remains constantly at "11%" (one of 8 cores).
    – kdb
    Mar 1 '19 at 19:13
  • "toggle-debug-on-quit and C-g don't trigger the debugger" - not at all? Are you didn't toggle debug-on-quit off by accident?
    – npostavs
    Mar 1 '19 at 20:15
5

@npostavs' last comment should give you enough hints to solve the problem. The built-in profiler can tell which function is causing the high CPU usage.

Here are simple steps to get started:

  1. (profiler-start)
  2. select 'cpu'
  3. wait for a few seconds
  4. (profiler-report)
  5. modify emacs e.g. by disabling the conflicting mode
  6. (profiler-stop)
  7. repeat to continue testing

More details in the Profiling Emacs manual page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.