From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: Interesting problem: eval-after-load and local variables Date: Thu, 18 Oct 2012 11:46:49 -0600 Message-ID: <20121018174648.GA9082@hysteria.proulx.com> References: <80y5j6etfl.fsf@somewhere.org> <808vb58pmw.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1350582419 10862 80.91.229.3 (18 Oct 2012 17:46:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Oct 2012 17:46:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 18 19:47:07 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TOuBW-0007IL-9Q for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2012 19:47:06 +0200 Original-Received: from localhost ([::1]:50696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOuBP-0004zo-3v for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2012 13:46:59 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOuBI-0004yz-WF for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 13:46:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOuBH-0000Pc-I6 for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 13:46:52 -0400 Original-Received: from joseki.proulx.com ([216.17.153.58]:51934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOuBH-0000PS-A6 for help-gnu-emacs@gnu.org; Thu, 18 Oct 2012 13:46:51 -0400 Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id E370C211D6 for ; Thu, 18 Oct 2012 11:46:49 -0600 (MDT) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id 3BD812DCD1; Thu, 18 Oct 2012 11:46:49 -0600 (MDT) Mail-Followup-To: Bob Proulx , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 216.17.153.58 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87318 Archived-At: Kevin Rodgers wrote: > Sebastien Vauban wrote: > > I know. And this is a very somewhat ridiculous example. But, for > > speed and clarity of my .emacs, I've generally put all customs > > inside an eval-after-load. A setq is certainly not time-taker, > > certainly not when alone, but I've applied the same principal to > > many other blocks of customs. > > I don't see how the eval-after-load boilerplate provides any speed > or clarity. I don't know about clarity, although it is nice to know where things are used, but it can save a very large amount of time when you are loading up a lot of various bits of emacs functionality. Things start up fairly quickly when doing nothing. $ time emacs -Q -f kill-emacs real 0m0.820s user 0m0.088s sys 0m0.040s But on a system where I have many things being loaded with require this and require that and all of those are required to be loaded before I have a working emacs and can see and type in anything: $ time emacs -f kill-emacs real 0m8.362s user 0m0.580s sys 0m0.168s That is a *HUGE* difference. By making use of eval-after-load I have reduced that startup time to this. It isn't on the same system and not directly comparable to the above so I will show both times for comparison. And it is on these slower systems where the full load times were very long and motivated me to optimize the startup. $ time emacs -Q -f kill-emacs real 0m1.940s user 0m0.156s sys 0m0.060s $ time emacs -f kill-emacs real 0m2.423s user 0m0.260s sys 0m0.132s And I still have a ways to go. (Just noting that in the above I dropped caches between runs making those cold disk accesses for all.) It was more than 2x slower and the original startup time of the fully loaded emacs with lots of requires was around 18 seconds. Getting that down to less than 2.5 seconds was a huge win. Now I need to go back and hit my original machine and get that 8 second load time now. Using eval-after-load and lazy-loading libraries on demand as they are needed can be a huge startup speed improvement over simply requiring libraries and loading every possible thing at every startup. You probably aren't going to ise it. And if you do then you can load it then. Bob