From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Steinar Bang Newsgroups: gmane.emacs.help Subject: Re: How to profile restoring from .emacs.desktop Date: Thu, 28 Jan 2021 18:51:25 +0100 Message-ID: <86v9bhlzky.fsf@dod.no> References: <864kj2nw2s.fsf@dod.no> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34155"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 28 19:06:00 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l5Bg8-0008gl-L0 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 28 Jan 2021 19:06:00 +0100 Original-Received: from localhost ([::1]:40544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5Bg7-0000n0-MI for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 28 Jan 2021 13:05:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5BSO-0007FF-Ga for help-gnu-emacs@gnu.org; Thu, 28 Jan 2021 12:51:48 -0500 Original-Received: from cadalora.default.sbang.uk0.bigv.io ([46.43.15.90]:56024) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5BSJ-00032h-0Z for help-gnu-emacs@gnu.org; Thu, 28 Jan 2021 12:51:48 -0500 Original-Received: from mccoy (cm-84.210.87.211.getinternet.no [84.210.87.211]) by cadalora.default.sbang.uk0.bigv.io (Postfix) with ESMTPSA id 581FECD42E for ; Thu, 28 Jan 2021 17:51:25 +0000 (GMT) In-Reply-To: (Stefan Monnier's message of "Wed, 27 Jan 2021 12:42:17 -0500") Received-SPF: none client-ip=46.43.15.90; envelope-from=sb@dod.no; helo=cadalora.default.sbang.uk0.bigv.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127404 Archived-At: >>>>> Stefan Monnier : > 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% - # 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% + # 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%