10

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. Commented Feb 27, 2019 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. Commented Feb 27, 2019 at 16:38
  • You can keep an eye on the Task Manager tray icon which would show when CPU usage is up. Commented Feb 27, 2019 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). Commented Mar 1, 2019 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? Commented Mar 1, 2019 at 20:15

1 Answer 1

9

@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. M-x profiler-start RET
  2. select 'cpu'
  3. wait for a few seconds
  4. M-x profiler-report RET
  5. modify emacs e.g. by disabling the conflicting mode
  6. M-x profiler-stop RET
  7. repeat to continue testing

More details in the Profiling Emacs manual page.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.