help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to profile restoring from .emacs.desktop


From: Steinar Bang
Subject: Re: How to profile restoring from .emacs.desktop
Date: Thu, 28 Jan 2021 18:51:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt)

>>>>> Stefan Monnier <monnier@iro.umontreal.ca>:

> Hi Steinar,
>> Is it possible to profile the restore from .emacs.desktop in some way?

> You can add

>     (profiler-start 'cpu)

> in your init file somewhere before loading the `.emacs.desktop` and then
> call `M-x profiler-report` when the startup is done

Thanks, Stefan!

I did exactly that:
 1. Put (profiler-start 'cpu) at the end of ~/.emacs
 2. Did `M-x profiler-report` after the startup has completed

And it worked perfectly!

I succeeded in saving the profile to a file.  I have no idea how/if it
can be loaded from that file, but the saved profile is here:
 https://gist.github.com/steinarb/fbb854a40f058cf561cbc333f64bc967

But a deep analysis probably isn't necessary, opening the biggest nodes
in the profile, it's pretty obvious that the biggest culprit is
projectile-discover-projects-in-directory the function it calls, with
the biggest chunks, before it all breaks down into many small things,
are projectile-serialize and projectile-difference.

So it's projectile project discovery that spends most of the time.
I wonder if that information can be cached...?

Here's the profiler tree with the most interesting (to me) nodes opened:

- normal-top-level                                             116518  92%
 - command-line                                                116518  92%
  - command-line-1                                             116510  92%
   - eval                                                      116506  92%
    - progn                                                    116506  92%
     - desktop-read                                            116506  92%
      - load                                                   116355  92%
       - load-with-code-conversion                             116355  92%
        - eval-buffer                                          116346  92%
         - desktop-create-buffer                               116281  92%
          - projectile-mode                                    102201  81%
           - projectile-discover-projects-in-search-path              96086  76%
            - mapcar                                            96086  76%
             - projectile-discover-projects-in-directory              96086  76%
              - mapcar                                          95579  75%
               - #<compiled 0x10bffb5>                          95540  75%
                - projectile-add-known-project                  90190  71%
                 - projectile-merge-known-projects              85962  68%
                  - projectile-save-known-projects              45969  36%
                   - projectile-serialize                       43930  34%
                    + write-region                              11854   9%
                    + #<compiled 0x134d99d>                      1988   1%
                    + get-buffer-create                           106   0%
                  - projectile-difference                       18874  14%
                   - cl-remove-if                               18650  14%
                    - apply                                     18631  14%
                       cl-remove                                12671  10%
                  + projectile-unserialize                      15287  12%
                    delete-dups                                  3281   2%
                 + abbreviate-file-name                          1425   1%
                   delete-dups                                   1081   0%
                 + projectile-ignored-project-p                    37   0%
                + projectile-project-p                           4587   3%
                directory-files                                    13   0%
           + projectile--cleanup-known-projects                  5784   4%
           + projectile-load-known-projects                       210   0%
           + projectile-commander-bindings                         53   0%
           + advice-add                                            36   0%
           + called-interactively-p                                 3   0%
             add-hook                                               2   0%
          + desktop-restore-file-buffer                          7532   5%
          + dired-restore-desktop-buffer                         3346   2%
          + desktop-load-file                                    1498   1%
          + bury-buffer                                          1081   0%
          + rename-buffer                                         476   0%
          + auto-revert-mode                                       71   0%
          + flycheck-mode                                          12   0%
          + editorconfig-mode                                       9   0%
          + nxml-psgml-compatibility-mode                           4   0%
            buffer-list                                             4   0%
          + auto-fill-mode                                          4   0%
         + internal-macroexpand-for-load                           11   0%
        + do-after-load-evaluation                                  9   0%
      + desktop-restore-frameset                                  147   0%
      + byte-code                                                   4   0%
  + lisp-interaction-mode                                           4   0%
- ...                                                            8332   6%
   Automatic GC                                                  8299   6%
 + minibuffer-complete                                             25   0%
 + cl--generic-get-dispatcher                                       4   0%
 + rng-compute-start-tag-close-deriv                                4   0%
+ timer-event-handler                                            1021   0%
+ command-execute                                                 108   0%
+ redisplay_internal (C function)                                  67   0%
+ flycheck-handle-signal                                           12   0%
+ flycheck-hide-error-buffer                                        3   0%



reply via email to

[Prev in Thread] Current Thread [Next in Thread]