Subject: Re: bug#16995: 24.3; CPU usage spikes to 100% for minutes at a time

From: Andrew Beekhof <[email-masked]>
Date: Mon, 17 Mar 2014 16:12:33 +1100

On 14 Mar 2014, at 12:40 am, Stefan Monnier <[email-masked]> wrote:

>> So I guess the question now becomes why does Python mode conses so
>> many Lisp objects that it triggers GC so frequently.
> 
> M-x profiler-start RET mem RET
> ...reproduce the heavy allocation problem...
> M-x profiler-report RET
> 
> might be a good start.

bwahahaha. I can go one better and give you a reproducer.
Time wasn't a factor, it was switching to a particular file that triggered the (worst of the) problem.

http://paste.fedoraproject.org/85549/13948345/

I had a bug in the file that was causing issues for soemthing:

@@ -90,7 +92,7 @@ class CTSTest:
         self.logger.log(args)
 
     def debug(self, args):
-        self.logger.debug(args
+        self.logger.debug(args)

Clearly user error, but ideally emacs wouldn't grind to a halt as a result.

Here's the profiler report.

+ timer-event-handler                                     278,246,734  42%
+ which-func-update                                       163,238,117  24%
+ redisplay_internal (C function)                          87,767,721  13%
+ which-func-update-1                                      48,416,290   7%
+ call-interactively                                       35,478,972   5%
+ apply                                                    18,737,232   2%
+ byte-code                                                 5,265,147   0%
+ which-function                                            4,192,656   0%
+ jit-lock-function                                         2,876,348   0%
+ redisplay                                                 2,237,092   0%
+ sit-for                                                   1,867,352   0%
+ read-from-minibuffer                                      1,418,935   0%
+ find-file                                                 1,333,035   0%
+ xselect-convert-to-string                                   810,557   0%
+ vc-state-refresh                                            698,757   0%
+ isearch-lazy-highlight-new-loop                             649,320   0%
+ isearch-update                                              589,542   0%
+ minibuffer-message                                          208,140   0%
+ completion--message                                         168,120   0%
+ isearch-process-search-string                               153,114   0%
+ isearch-search-and-update                                   145,286   0%
+ jit-lock-fontify-now                                        136,240   0%
+ x-set-selection                                              82,873   0%
+ minibuffer-complete                                          46,642   0%
+ completion--do-completion                                    38,266   0%
+ deactivate-mark                                              36,976   0%
+ run-hook-with-args-until-success                             24,764   0%
+ run-hooks                                                    22,286   0%
+ run-hook-with-args                                           17,952   0%
+ xselect-convert-to-targets                                   17,443   0%
+ find-file-noselect                                           12,432   0%
+ self-insert-command                                           8,188   0%
+ c-mode                                                        8,188   0%
+ find-tag                                                      7,000   0%
+ mouse-fixup-help-message                                      6,144   0%
+ find-file-read-args                                           5,120   0%
+ funcall                                                       4,096   0%
+ vc-find-file-hook                                             3,720   0%
+ vc-registered                                                 2,487   0%
+ find-file-noselect-1                                          2,026   0%
+ file-truename                                                 1,260   0%