GNU bug report logs - #4287
reducing emacs size by more frequent garbage-collect calls in loadup.el

Previous Next

Package: emacs;

Reported by: Dan Nicolaescu <dann <at> ics.uci.edu>

Date: Sat, 29 Aug 2009 18:45:05 UTC

Severity: normal

Done: Dan Nicolaescu <dann <at> ics.uci.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 4287 in the body.
You can then email your comments to 4287 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sat, 29 Aug 2009 18:45:05 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Sat, 29 Aug 2009 11:41:58 -0700 (PDT)
As the Subject says, replacing each `load' line in loadup.el with 
`load' + `garbage-collect' will reduce the size of the stripped emacs
binary: (.7 is before, .8 is after the change)

$ ls -l emacs-23.1.50.8 emacs-23.1.50.7
-rwx------ 1 dann dann 6722788 Jul 24 14:20 emacs-23.1.50.8*
-rwx------ 1 dann dann 6857956 Jul 24 14:20 emacs-23.1.50.7*

$ size  emacs-23.1.50.8 emacs-23.1.50.7
   text    data     bss     dec     hex filename
1883659 4833256       0 6716915  667df3 emacs-23.1.50.8
1883659 4968424       0 6852083  688df3 emacs-23.1.50.7

so we get about 2% reduction by doing something very simple and safe... 

[This happens because loading multiple files generate more garbage that
can be collected, but it is not returned to the OS, so it appears in
the dumped image].

See the discussion on this topic on emacs-devel:
http://permalink.gmane.org/gmane.emacs.devel/113176





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sat, 29 Aug 2009 21:40:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 29 Aug 2009 21:40:06 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4287 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Sat, 29 Aug 2009 17:34:35 -0400
> As the Subject says, replacing each `load' line in loadup.el with 
> `load' + `garbage-collect' will reduce the size of the stripped emacs
> binary: (.7 is before, .8 is after the change)

> $ ls -l emacs-23.1.50.8 emacs-23.1.50.7
> -rwx------ 1 dann dann 6722788 Jul 24 14:20 emacs-23.1.50.8*
> -rwx------ 1 dann dann 6857956 Jul 24 14:20 emacs-23.1.50.7*

> $ size  emacs-23.1.50.8 emacs-23.1.50.7
>    text    data     bss     dec     hex filename
> 1883659 4833256       0 6716915  667df3 emacs-23.1.50.8
> 1883659 4968424       0 6852083  688df3 emacs-23.1.50.7

> so we get about 2% reduction by doing something very simple and safe... 

> [This happens because loading multiple files generate more garbage that
> can be collected, but it is not returned to the OS, so it appears in
> the dumped image].

> See the discussion on this topic on emacs-devel:
> http://permalink.gmane.org/gmane.emacs.devel/113176

Can you show the patch?


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sat, 29 Aug 2009 21:40:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 29 Aug 2009 21:40:08 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sun, 30 Aug 2009 06:15:05 GMT) Full text and rfc822 format available.

Message #16 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Sat, 29 Aug 2009 23:09:10 -0700 (PDT)
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

  > > As the Subject says, replacing each `load' line in loadup.el with 
  > > `load' + `garbage-collect' will reduce the size of the stripped emacs
  > > binary: (.7 is before, .8 is after the change)
  > 
  > > $ ls -l emacs-23.1.50.8 emacs-23.1.50.7
  > > -rwx------ 1 dann dann 6722788 Jul 24 14:20 emacs-23.1.50.8*
  > > -rwx------ 1 dann dann 6857956 Jul 24 14:20 emacs-23.1.50.7*
  > 
  > > $ size  emacs-23.1.50.8 emacs-23.1.50.7
  > >    text    data     bss     dec     hex filename
  > > 1883659 4833256       0 6716915  667df3 emacs-23.1.50.8
  > > 1883659 4968424       0 6852083  688df3 emacs-23.1.50.7
  > 
  > > so we get about 2% reduction by doing something very simple and safe... 
  > 
  > > [This happens because loading multiple files generate more garbage that
  > > can be collected, but it is not returned to the OS, so it appears in
  > > the dumped image].
  > 
  > > See the discussion on this topic on emacs-devel:
  > > http://permalink.gmane.org/gmane.emacs.devel/113176
  > 
  > Can you show the patch?

Sure:

--- loadup.el.~1.180.~	2009-08-20 23:31:53.000000000 -0700
+++ loadup.el	2009-08-29 23:02:34.000000000 -0700
@@ -57,30 +57,49 @@
 (setq buffer-undo-list t)
 
 (load "emacs-lisp/byte-run")
+(garbage-collect)
 (load "emacs-lisp/backquote")
+(garbage-collect)
 (load "subr")
+(garbage-collect)
 
 ;; We specify .el in case someone compiled version.el by mistake.
 (load "version.el")
+(garbage-collect)
 
 (load "widget")
+(garbage-collect)
 (load "custom")
+(garbage-collect)
 (load "emacs-lisp/map-ynp")
+(garbage-collect)
 (load "cus-start")
+(garbage-collect)
 (load "international/mule")
+(garbage-collect)
 (load "international/mule-conf.el") ;Don't get confused if someone compiled this by mistake.
+(garbage-collect)
 (load "env")
+(garbage-collect)
 (load "format")
+(garbage-collect)
 (load "bindings")
+(garbage-collect)
 (setq load-source-file-function 'load-with-code-conversion)
 (load "files")
+(garbage-collect)
 
 (load "cus-face")
+(garbage-collect)
 (load "faces")  ; after here, `defface' may be used.
+(garbage-collect)
 (load "minibuffer")
+(garbage-collect)
 
 (load "button")
+(garbage-collect)
 (load "startup")
+(garbage-collect)
 
 (message "Lists of integers (garbage collection statistics) are normal output")
 (message "while building Emacs; they do not indicate a problem.")
@@ -94,133 +113,220 @@
 
 (message "%s" (garbage-collect))
 (load "abbrev")         ;lisp-mode.el and simple.el use define-abbrev-table.
+(garbage-collect)
 (load "simple")
+(garbage-collect)
 
 (load "help")
+(garbage-collect)
 
 (load "jka-cmpr-hook")
+(garbage-collect)
 (load "epa-hook")
+(garbage-collect)
 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
 ;; multilingual text.
 (load "international/mule-cmds")
+(garbage-collect)
 (load "case-table")
+(garbage-collect)
 (load "international/characters")
+(garbage-collect)
 (load "composite")
+(garbage-collect)
 ;; This file doesn't exist when building Emacs from CVS.  It is
 ;; generated just after temacs is build.
 (load "international/charprop.el" t)
+(garbage-collect)
 
 ;; Load language-specific files.
 (load "language/chinese")
+(garbage-collect)
 (load "language/cyrillic")
+(garbage-collect)
 (load "language/indian")
+(garbage-collect)
 (load "language/sinhala")
+(garbage-collect)
 (load "language/english")
+(garbage-collect)
 (load "language/ethiopic")
+(garbage-collect)
 (load "language/european")
+(garbage-collect)
 (load "language/czech")
+(garbage-collect)
 (load "language/slovak")
+(garbage-collect)
 (load "language/romanian")
+(garbage-collect)
 (load "language/greek")
+(garbage-collect)
 (load "language/hebrew")
+(garbage-collect)
 (load "language/japanese")
+(garbage-collect)
 (load "language/korean")
+(garbage-collect)
 (load "language/lao")
+(garbage-collect)
 (load "language/tai-viet")
+(garbage-collect)
 (load "language/thai")
+(garbage-collect)
 (load "language/tibetan")
+(garbage-collect)
 (load "language/vietnamese")
+(garbage-collect)
 (load "language/misc-lang")
+(garbage-collect)
 (load "language/utf-8-lang")
+(garbage-collect)
 (load "language/georgian")
+(garbage-collect)
 (load "language/khmer")
+(garbage-collect)
 (load "language/burmese")
+(garbage-collect)
 (load "language/cham")
+(garbage-collect)
 
 (load "indent")
+(garbage-collect)
 (load "window")
+(garbage-collect)
 (load "frame")
+(garbage-collect)
 (load "term/tty-colors")
+(garbage-collect)
 (load "font-core")
+(garbage-collect)
 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
 ;; needs to be defined when font-lock is loaded.
 (load "facemenu")
+(garbage-collect)
 (load "emacs-lisp/syntax")
+(garbage-collect)
 (load "font-lock")
+(garbage-collect)
 (load "jit-lock")
+(garbage-collect)
 
 (if (fboundp 'track-mouse)
     (progn
       (load "mouse")
+      (garbage-collect)
       (and (boundp 'x-toolkit-scroll-bars)
-	   (load "scroll-bar"))
-      (load "select")))
+	   (load "scroll-bar")
+	   (garbage-collect))
+      (load "select")
+      (garbage-collect)))
 (load "emacs-lisp/timer")
+(garbage-collect)
 (load "isearch")
+(garbage-collect)
 (load "rfn-eshadow")
+(garbage-collect)
 
 (message "%s" (garbage-collect))
 (load "menu-bar")
+(garbage-collect)
 (load "paths.el")  ;Don't get confused if someone compiled paths by mistake.
+(garbage-collect)
 (load "emacs-lisp/lisp")
+(garbage-collect)
 (load "textmodes/page")
+(garbage-collect)
 (load "register")
+(garbage-collect)
 (load "textmodes/paragraphs")
+(garbage-collect)
 (load "emacs-lisp/lisp-mode")
+(garbage-collect)
 (load "textmodes/text-mode")
+(garbage-collect)
 (load "textmodes/fill")
 (message "%s" (garbage-collect))
 
 (load "replace")
+(garbage-collect)
 (load "buff-menu")
+(garbage-collect)
 
 (if (fboundp 'x-create-frame)
     (progn
       (load "fringe")
+      (garbage-collect)
       (load "image")
+      (garbage-collect)
       (load "international/fontset")
+      (garbage-collect)
       (load "dnd")
+      (garbage-collect)
       (load "mwheel")
-      (load "tool-bar")))
+      (garbage-collect)
+      (load "tool-bar")
+      (garbage-collect)))
 (if (featurep 'x)
     (progn
       (load "x-dnd")
+      (garbage-collect)
       (load "term/common-win")
-      (load "term/x-win")))
+      (garbage-collect)
+      (load "term/x-win")
+      (garbage-collect)))
 
 (message "%s" (garbage-collect))
 
 (if (eq system-type 'windows-nt)
     (progn
       (load "w32-vars")
+      (garbage-collect)
       (load "term/common-win")
+      (garbage-collect)
       (load "term/w32-win")
+      (garbage-collect)
       (load "ls-lisp")
+      (garbage-collect)
       (load "disp-table")
+      (garbage-collect)
       (load "dos-w32")
-      (load "w32-fns")))
+      (garbage-collect)
+      (load "w32-fns")
+      (garbage-collect)))
 (if (eq system-type 'ms-dos)
     (progn
       (load "dos-w32")
+      (garbage-collect)
       (load "dos-fns")
+      (garbage-collect)
       (load "dos-vars")
+      (garbage-collect)
       ;; Don't load term/common-win: it isn't appropriate for the `pc'
       ;; ``window system'', which generally behaves like a terminal.
       (load "term/pc-win")
+      (garbage-collect)
       (load "ls-lisp")
-      (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
+      (garbage-collect)
+      (load "disp-table")
+      (garbage-collect))) ; needed to setup ibm-pc char set, see internal.el
 (if (featurep 'ns)
     (progn
       (load "emacs-lisp/easymenu")  ;; for platform-related menu adjustments
-      (load "term/ns-win")))
+      (garbage-collect)
+      (load "term/ns-win")
+      (garbage-collect)))
 (if (fboundp 'atan)	; preload some constants and
     (progn		; floating pt. functions if we have float support.
-      (load "emacs-lisp/float-sup")))
+      (load "emacs-lisp/float-sup")
+      (garbage-collect)))
 (message "%s" (garbage-collect))
 
 (load "vc-hooks")
+(garbage-collect)
 (load "ediff-hook")
-(if (fboundp 'x-show-tip) (load "tooltip"))
+(garbage-collect)
+(if (fboundp 'x-show-tip) (progn (load "tooltip") (garbage-collect)))
 
 (message "%s" (garbage-collect))
 



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sun, 30 Aug 2009 18:10:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sun, 30 Aug 2009 18:10:09 GMT) Full text and rfc822 format available.

Message #21 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: monnier <at> iro.umontreal.ca, 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect	calls in loadup.el
Date: Sun, 30 Aug 2009 21:00:33 +0300
> Date: Sat, 29 Aug 2009 23:09:10 -0700 (PDT)
> From: Dan Nicolaescu <dann <at> ics.uci.edu>
> Cc: 4287 <at> emacsbugs.donarmstrong.com
> 
> --- loadup.el.~1.180.~	2009-08-20 23:31:53.000000000 -0700
> +++ loadup.el	2009-08-29 23:02:34.000000000 -0700
> @@ -57,30 +57,49 @@
>  (setq buffer-undo-list t)
>  
>  (load "emacs-lisp/byte-run")
> +(garbage-collect)
>  (load "emacs-lisp/backquote")
> +(garbage-collect)
>  (load "subr")
> +(garbage-collect)
>  
>  ;; We specify .el in case someone compiled version.el by mistake.
>  (load "version.el")
> +(garbage-collect)

Perhaps a new function `load-and-gc' would be a good idea.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sun, 30 Aug 2009 20:10:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sun, 30 Aug 2009 20:10:06 GMT) Full text and rfc822 format available.

Message #26 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Sun, 30 Aug 2009 16:04:46 -0400
>> Can you show the patch?
> Sure:

Sorry, too ugly to be worth the few bytes (especially since these are
bytes you'll be using anyway as soon as you start Emacs).


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Sun, 30 Aug 2009 20:50:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sun, 30 Aug 2009 20:50:07 GMT) Full text and rfc822 format available.

Message #31 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect 
	calls in loadup.el
Date: Sun, 30 Aug 2009 22:45:03 +0200
On Sun, Aug 30, 2009 at 22:04, Stefan Monnier<monnier <at> iro.umontreal.ca> wrote:

> Sorry, too ugly to be worth the few bytes (especially since these are
> bytes you'll be using anyway as soon as you start Emacs).

I've often wondered why there is no `after-load-hook' or
`after-load-functions', run directly from (the end of) Fload. Then we
could do now

--- loadup.el	21 Aug 2009 06:19:28 -0000	1.180
+++ loadup.el	30 Aug 2009 20:44:10 -0000
@@ -57,4 +57,5 @@
 (setq buffer-undo-list t)

+(add-hook 'after-load-hook 'garbage-collect)
 (load "emacs-lisp/byte-run")
 (load "emacs-lisp/backquote")
@@ -286,4 +287,5 @@
 (load "site-init" t)
 (setq current-load-list nil)
+(remove-hook 'after-load-hook 'garbage-collect)

 ;; Write the value of load-history into fns-VERSION.el,

which is not so easy or elegant with `after-load-alist' (whose
regexp-matching functionality is implemented in elisp, AFAICS).

    Juanma



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Mon, 31 Aug 2009 00:05:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 31 Aug 2009 00:05:07 GMT) Full text and rfc822 format available.

Message #36 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org, Dan Nicolaescu <dann <at> ics.uci.edu>
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Mon, 31 Aug 2009 02:55:55 +0300
>>> Can you show the patch?
>> Sure:
>
> Sorry, too ugly to be worth the few bytes (especially since these are
> bytes you'll be using anyway as soon as you start Emacs).

Can't we set gc-cons-percentage or gc-cons-threshold to a lower value
in loadup.el to more frequent GC?

-- 
Juri Linkov
http://www.jurta.org/emacs/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Mon, 31 Aug 2009 04:30:03 GMT) Full text and rfc822 format available.

Message #39 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Sun, 30 Aug 2009 21:25:54 -0700 (PDT)
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

  > >> Can you show the patch?
  > > Sure:
  > 
  > Sorry, too ugly to be worth the few bytes (especially since these are
  > bytes you'll be using anyway as soon as you start Emacs).

How about another suggested method that is not ugly: a load-and-gc
function?



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Mon, 31 Aug 2009 14:55:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 31 Aug 2009 14:55:10 GMT) Full text and rfc822 format available.

Message #44 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect
Date: Mon, 31 Aug 2009 10:46:32 -0400
>> Sorry, too ugly to be worth the few bytes (especially since these are
>> bytes you'll be using anyway as soon as you start Emacs).

> I've often wondered why there is no `after-load-hook' or
> `after-load-functions', run directly from (the end of) Fload. Then we
> could do now

We could replace the call from C to do-after-load-evaluation by
Frun_hooks(Qafter-load-functions), either passing it the file name
explicitly or making sure load-file-name is still set.

> which is not so easy or elegant with `after-load-alist' (whose
> regexp-matching functionality is implemented in elisp, AFAICS).

Doesn't something like (push '("" (garbage-collect)) after-load-alist)
do the trick?  Oh I see it doesn't because we check purify-flag.
Clearly this check could be removed if we use after-load-functions.


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Mon, 31 Aug 2009 14:55:14 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 31 Aug 2009 14:55:14 GMT) Full text and rfc822 format available.

Message #49 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Mon, 31 Aug 2009 10:49:37 -0400
>> >> Can you show the patch?
>> > Sure:
>> Sorry, too ugly to be worth the few bytes (especially since these are
>> bytes you'll be using anyway as soon as you start Emacs).
> How about another suggested method that is not ugly: a load-and-gc
> function?

Could be.  The devil is in the details, so without the patch it's hard
to judge.


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Tue, 01 Sep 2009 01:00:15 GMT) Full text and rfc822 format available.

Message #52 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Mon, 31 Aug 2009 17:57:54 -0700 (PDT)
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

  > >> >> Can you show the patch?
  > >> > Sure:
  > >> Sorry, too ugly to be worth the few bytes (especially since these are
  > >> bytes you'll be using anyway as soon as you start Emacs).
  > > How about another suggested method that is not ugly: a load-and-gc
  > > function?
  > 
  > Could be.  The devil is in the details, so without the patch it's hard
  > to judge.

Here's one.
The function name can be adjusted to be more specific if needed, and the
fmakunbound call is not necessarily needed...


--- loadup.el.~1.180.~	2009-08-20 23:31:53.000000000 -0700
+++ loadup.el	2009-08-31 17:55:33.000000000 -0700
@@ -56,31 +56,35 @@
 (set-buffer "*scratch*")
 (setq buffer-undo-list t)
 
-(load "emacs-lisp/byte-run")
-(load "emacs-lisp/backquote")
-(load "subr")
+(defun load-and-gc (file &optional noerror nomessage nosuffix must-suffix)
+  (load file noerror nomessage nosuffix must-suffix)
+  (garbage-collect))
+
+(load-and-gc "emacs-lisp/byte-run")
+(load-and-gc "emacs-lisp/backquote")
+(load-and-gc "subr")
 
 ;; We specify .el in case someone compiled version.el by mistake.
-(load "version.el")
+(load-and-gc "version.el")
 
-(load "widget")
-(load "custom")
-(load "emacs-lisp/map-ynp")
-(load "cus-start")
-(load "international/mule")
-(load "international/mule-conf.el") ;Don't get confused if someone compiled this by mistake.
-(load "env")
-(load "format")
-(load "bindings")
+(load-and-gc "widget")
+(load-and-gc "custom")
+(load-and-gc "emacs-lisp/map-ynp")
+(load-and-gc "cus-start")
+(load-and-gc "international/mule")
+(load-and-gc "international/mule-conf.el") ;Don't get confused if someone compiled this by mistake.
+(load-and-gc "env")
+(load-and-gc "format")
+(load-and-gc "bindings")
 (setq load-source-file-function 'load-with-code-conversion)
-(load "files")
+(load-and-gc "files")
 
-(load "cus-face")
-(load "faces")  ; after here, `defface' may be used.
-(load "minibuffer")
+(load-and-gc "cus-face")
+(load-and-gc "faces")  ; after here, `defface' may be used.
+(load-and-gc "minibuffer")
 
-(load "button")
-(load "startup")
+(load-and-gc "button")
+(load-and-gc "startup")
 
 (message "Lists of integers (garbage collection statistics) are normal output")
 (message "while building Emacs; they do not indicate a problem.")
@@ -88,139 +92,139 @@
 
 (condition-case nil
     ;; Don't get confused if someone compiled this by mistake.
-    (load "loaddefs.el")
+    (load-and-gc "loaddefs.el")
   ;; In case loaddefs hasn't been generated yet.
-  (file-error (load "ldefs-boot.el")))
+  (file-error (load-and-gc "ldefs-boot.el")))
 
 (message "%s" (garbage-collect))
-(load "abbrev")         ;lisp-mode.el and simple.el use define-abbrev-table.
-(load "simple")
+(load-and-gc "abbrev")         ;lisp-mode.el and simple.el use define-abbrev-table.
+(load-and-gc "simple")
 
-(load "help")
+(load-and-gc "help")
 
-(load "jka-cmpr-hook")
-(load "epa-hook")
+(load-and-gc "jka-cmpr-hook")
+(load-and-gc "epa-hook")
 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
 ;; multilingual text.
-(load "international/mule-cmds")
-(load "case-table")
-(load "international/characters")
-(load "composite")
+(load-and-gc "international/mule-cmds")
+(load-and-gc "case-table")
+(load-and-gc "international/characters")
+(load-and-gc "composite")
 ;; This file doesn't exist when building Emacs from CVS.  It is
 ;; generated just after temacs is build.
-(load "international/charprop.el" t)
+(load-and-gc "international/charprop.el" t)
 
 ;; Load language-specific files.
-(load "language/chinese")
-(load "language/cyrillic")
-(load "language/indian")
-(load "language/sinhala")
-(load "language/english")
-(load "language/ethiopic")
-(load "language/european")
-(load "language/czech")
-(load "language/slovak")
-(load "language/romanian")
-(load "language/greek")
-(load "language/hebrew")
-(load "language/japanese")
-(load "language/korean")
-(load "language/lao")
-(load "language/tai-viet")
-(load "language/thai")
-(load "language/tibetan")
-(load "language/vietnamese")
-(load "language/misc-lang")
-(load "language/utf-8-lang")
-(load "language/georgian")
-(load "language/khmer")
-(load "language/burmese")
-(load "language/cham")
-
-(load "indent")
-(load "window")
-(load "frame")
-(load "term/tty-colors")
-(load "font-core")
+(load-and-gc "language/chinese")
+(load-and-gc "language/cyrillic")
+(load-and-gc "language/indian")
+(load-and-gc "language/sinhala")
+(load-and-gc "language/english")
+(load-and-gc "language/ethiopic")
+(load-and-gc "language/european")
+(load-and-gc "language/czech")
+(load-and-gc "language/slovak")
+(load-and-gc "language/romanian")
+(load-and-gc "language/greek")
+(load-and-gc "language/hebrew")
+(load-and-gc "language/japanese")
+(load-and-gc "language/korean")
+(load-and-gc "language/lao")
+(load-and-gc "language/tai-viet")
+(load-and-gc "language/thai")
+(load-and-gc "language/tibetan")
+(load-and-gc "language/vietnamese")
+(load-and-gc "language/misc-lang")
+(load-and-gc "language/utf-8-lang")
+(load-and-gc "language/georgian")
+(load-and-gc "language/khmer")
+(load-and-gc "language/burmese")
+(load-and-gc "language/cham")
+
+(load-and-gc "indent")
+(load-and-gc "window")
+(load-and-gc "frame")
+(load-and-gc "term/tty-colors")
+(load-and-gc "font-core")
 ;; facemenu must be loaded before font-lock, because `facemenu-keymap'
 ;; needs to be defined when font-lock is loaded.
-(load "facemenu")
-(load "emacs-lisp/syntax")
-(load "font-lock")
-(load "jit-lock")
+(load-and-gc "facemenu")
+(load-and-gc "emacs-lisp/syntax")
+(load-and-gc "font-lock")
+(load-and-gc "jit-lock")
 
 (if (fboundp 'track-mouse)
     (progn
-      (load "mouse")
+      (load-and-gc "mouse")
       (and (boundp 'x-toolkit-scroll-bars)
-	   (load "scroll-bar"))
-      (load "select")))
-(load "emacs-lisp/timer")
-(load "isearch")
-(load "rfn-eshadow")
+	   (load-and-gc "scroll-bar"))
+      (load-and-gc "select")))
+(load-and-gc "emacs-lisp/timer")
+(load-and-gc "isearch")
+(load-and-gc "rfn-eshadow")
 
 (message "%s" (garbage-collect))
-(load "menu-bar")
-(load "paths.el")  ;Don't get confused if someone compiled paths by mistake.
-(load "emacs-lisp/lisp")
-(load "textmodes/page")
-(load "register")
-(load "textmodes/paragraphs")
-(load "emacs-lisp/lisp-mode")
-(load "textmodes/text-mode")
-(load "textmodes/fill")
+(load-and-gc "menu-bar")
+(load-and-gc "paths.el")  ;Don't get confused if someone compiled paths by mistake.
+(load-and-gc "emacs-lisp/lisp")
+(load-and-gc "textmodes/page")
+(load-and-gc "register")
+(load-and-gc "textmodes/paragraphs")
+(load-and-gc "emacs-lisp/lisp-mode")
+(load-and-gc "textmodes/text-mode")
+(load-and-gc "textmodes/fill")
 (message "%s" (garbage-collect))
 
-(load "replace")
-(load "buff-menu")
+(load-and-gc "replace")
+(load-and-gc "buff-menu")
 
 (if (fboundp 'x-create-frame)
     (progn
-      (load "fringe")
-      (load "image")
-      (load "international/fontset")
-      (load "dnd")
-      (load "mwheel")
-      (load "tool-bar")))
+      (load-and-gc "fringe")
+      (load-and-gc "image")
+      (load-and-gc "international/fontset")
+      (load-and-gc "dnd")
+      (load-and-gc "mwheel")
+      (load-and-gc "tool-bar")))
 (if (featurep 'x)
     (progn
-      (load "x-dnd")
-      (load "term/common-win")
-      (load "term/x-win")))
+      (load-and-gc "x-dnd")
+      (load-and-gc "term/common-win")
+      (load-and-gc "term/x-win")))
 
 (message "%s" (garbage-collect))
 
 (if (eq system-type 'windows-nt)
     (progn
-      (load "w32-vars")
-      (load "term/common-win")
-      (load "term/w32-win")
-      (load "ls-lisp")
-      (load "disp-table")
-      (load "dos-w32")
-      (load "w32-fns")))
+      (load-and-gc "w32-vars")
+      (load-and-gc "term/common-win")
+      (load-and-gc "term/w32-win")
+      (load-and-gc "ls-lisp")
+      (load-and-gc "disp-table")
+      (load-and-gc "dos-w32")
+      (load-and-gc "w32-fns")))
 (if (eq system-type 'ms-dos)
     (progn
-      (load "dos-w32")
-      (load "dos-fns")
-      (load "dos-vars")
+      (load-and-gc "dos-w32")
+      (load-and-gc "dos-fns")
+      (load-and-gc "dos-vars")
       ;; Don't load term/common-win: it isn't appropriate for the `pc'
       ;; ``window system'', which generally behaves like a terminal.
-      (load "term/pc-win")
-      (load "ls-lisp")
-      (load "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
+      (load-and-gc "term/pc-win")
+      (load-and-gc "ls-lisp")
+      (load-and-gc "disp-table"))) ; needed to setup ibm-pc char set, see internal.el
 (if (featurep 'ns)
     (progn
-      (load "emacs-lisp/easymenu")  ;; for platform-related menu adjustments
-      (load "term/ns-win")))
+      (load-and-gc "emacs-lisp/easymenu")  ;; for platform-related menu adjustments
+      (load-and-gc "term/ns-win")))
 (if (fboundp 'atan)	; preload some constants and
     (progn		; floating pt. functions if we have float support.
-      (load "emacs-lisp/float-sup")))
+      (load-and-gc "emacs-lisp/float-sup")))
 (message "%s" (garbage-collect))
 
-(load "vc-hooks")
-(load "ediff-hook")
-(if (fboundp 'x-show-tip) (load "tooltip"))
+(load-and-gc "vc-hooks")
+(load-and-gc "ediff-hook")
+(if (fboundp 'x-show-tip) (load-and-gc "tooltip"))
 
 (message "%s" (garbage-collect))
 
@@ -283,9 +287,12 @@
 ;;;Note: You can cause additional libraries to be preloaded
 ;;;by writing a site-init.el that loads them.
 ;;;See also "site-load" above.
-(load "site-init" t)
+(load-and-gc "site-init" t)
 (setq current-load-list nil)
 
+;; Unbound the function, we don't need it elsewhere.
+(fmakunbound 'load-and-gc)
+
 ;; Write the value of load-history into fns-VERSION.el,
 ;; then clear out load-history.
 ;; (if (or (equal (nth 3 command-line-args) "dump")



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Tue, 01 Sep 2009 11:50:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 01 Sep 2009 11:50:07 GMT) Full text and rfc822 format available.

Message #57 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect
Date: Tue, 1 Sep 2009 13:44:44 +0200
On Mon, Aug 31, 2009 at 16:46, Stefan Monnier<monnier <at> iro.umontreal.ca> wrote:

> We could replace the call from C to do-after-load-evaluation by
> Frun_hooks(Qafter-load-functions), either passing it the file name
> explicitly or making sure load-file-name is still set.

I think this would be a worthwhile change (regardless of the chosen
fix for the "load + gc" issue on startup.el).

    Juanma



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Tue, 01 Sep 2009 16:30:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 01 Sep 2009 16:30:07 GMT) Full text and rfc822 format available.

Message #62 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect
Date: Tue, 01 Sep 2009 12:21:36 -0400
>> We could replace the call from C to do-after-load-evaluation by
>> Frun_hooks(Qafter-load-functions), either passing it the file name
>> explicitly or making sure load-file-name is still set.

> I think this would be a worthwhile change (regardless of the chosen
> fix for the "load + gc" issue on startup.el).

Patches welcome,


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4287; Package emacs. (Tue, 01 Sep 2009 21:35:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 01 Sep 2009 21:35:04 GMT) Full text and rfc822 format available.

Message #67 received at 4287 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4287 <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect
Date: Tue, 1 Sep 2009 23:33:55 +0200
On Tue, Sep 1, 2009 at 18:21, Stefan Monnier<monnier <at> iro.umontreal.ca> wrote:

>> I think this would be a worthwhile change (regardless of the chosen
>> fix for the "load + gc" issue on startup.el).
>
> Patches welcome,

Adding after-load-functions seems easy enough, but you say "replace
the call from C to do-after-load-evaluation". It is unclear to me how
do you propose to run do-after-load-evaluation then.

    Juanma



Reply sent to Dan Nicolaescu <dann <at> ics.uci.edu>:
You have taken responsibility. (Thu, 17 Sep 2009 06:25:07 GMT) Full text and rfc822 format available.

Notification sent to Dan Nicolaescu <dann <at> ics.uci.edu>:
bug acknowledged by developer. (Thu, 17 Sep 2009 06:25:07 GMT) Full text and rfc822 format available.

Message #72 received at 4287-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: 4287-done <at> debbugs.gnu.org
Subject: Re: bug#4287: reducing emacs size by more frequent garbage-collect calls in loadup.el
Date: Wed, 16 Sep 2009 23:17:57 -0700 (PDT)
This is done in CVS now.



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Thu, 15 Oct 2009 14:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 252 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.