Subject: Re: bug#24091: 24.5; High CPU usage at startup while hidden

From: Clément Pit--Claudel <[email-masked]>
Date: Thu, 28 Jul 2016 15:37:20 -0400

On 2016-07-28 13:43, aiken wrote:
> Clément: I still get the problem with `emacs -Q`. Some clarification
> about the problem: the high CPU usage starts while Emacs is launching on
> some other workspace, and stops as soon as I go to that workspace. I
> notice that, when I go to the Emacs workspace and see the Emacs window,
> Emacs hasn't actually loaded up fully (e.g. it hasn't loaded my
> init.el), and it only finishes a lot of its startup once I'm on that
> workspace. Anyway, since the problem stops as soon as I look at Emacs,
> the only way I know of running profiler-report for this purpose is by
> putting it in a command line option: `emacs -Q --eval "(profiler-start
> 'cpu)"`. So I've done this (see below for the report), but I'm pretty
> sure the profiler-start is only getting evaluated after I've moved to
> the Emacs workspace, i.e. after the problem has stopped.

Interesting, thanks. Indeed, the profile doesn't show much of interest, and does not seem to have run very long.
I'm not very knowledgeable at all about these parts of Emacs, so I hope that an expert can offer more suggestions. I can offer a few suggestions, however:

* You could try enabling C-level profiling, if you're fine with recompiling Emacs; this should capture most of Emacs' activity.
* You could try getting a backtrace while Emacs is busy starting, from the other desktop; either using gdb if it's busy in C-code, or with pkill -SIGUSR2 if it's busy with Lisp code.

Btw, was this profile obtained with Emacs 24.5, or 24.3?