From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Building Emacs overflowed pure space Date: Wed, 19 Jul 2006 11:05:39 -0400 Message-ID: References: <7dbe73ed0607180138x35e9d9bft3e42f20cb369795c@mail.gmail.com> <200607181929.k6IJTZN9028639@jane.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1153321609 9786 80.91.229.2 (19 Jul 2006 15:06:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Jul 2006 15:06:49 +0000 (UTC) Cc: emacs-devel@gnu.org, Luc Teirlinck , rms@gnu.org, ralphm@members.fsf.org, mathias.dahl@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 19 17:06:42 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G3DcU-0001mz-6F for ged-emacs-devel@m.gmane.org; Wed, 19 Jul 2006 17:05:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G3DcT-0003hX-Fs for ged-emacs-devel@m.gmane.org; Wed, 19 Jul 2006 11:05:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G3DcI-0003gF-Sk for emacs-devel@gnu.org; Wed, 19 Jul 2006 11:05:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G3DcI-0003fG-8X for emacs-devel@gnu.org; Wed, 19 Jul 2006 11:05:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G3DcI-0003fA-5i for emacs-devel@gnu.org; Wed, 19 Jul 2006 11:05:38 -0400 Original-Received: from [209.226.175.34] (helo=tomts13-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G3DfN-0000kf-Pv; Wed, 19 Jul 2006 11:08:49 -0400 Original-Received: from localhost ([70.53.192.251]) by tomts13-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20060719150532.WOIW29052.tomts13-srv.bellnexxia.net@localhost>; Wed, 19 Jul 2006 11:05:32 -0400 Original-Received: by localhost (Postfix, from userid 20848) id 9C88190A6; Wed, 19 Jul 2006 11:05:39 -0400 (EDT) Original-To: YAMAMOTO Mitsuharu In-Reply-To: (YAMAMOTO Mitsuharu's message of "Wed, 19 Jul 2006 18:46:44 +0900") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:57341 Archived-At: >> Dumped with dolist in subr.el: 1209808 bytes used >> dolist in cl.el: >1211000 bytes used (overflow) >> dolist in cl.el with the modification >> '--cl-dolist-temp-- -> '--dolist-temp-- : >> 1209832 bytes used Interesting. I'm wondering why you say "multiple of 8", since the pointer to the data part of a string is not a Lisp_Object but a plain pointer without any special alignment constraint AFAIK. Also `make-symbol' allocates a fixed amount of memory AFAIK, independent from the symbol name's length (it keeps a ref to the string argument, instead, so that (eq X (symbol-name (make-symbol X))) is always true), and the "--cl-dolist-temp--" string should only be allocated once (when reading the macro definition). So the only explanation that I can find is that the uninterned symbol names get copied to purespace at some point (don't know when or why), at which point the single shared string "--cl-dolist-temp--" gets copied N times. > (defmacro dolist (spec &rest body) > "Loop over a list. > Evaluate BODY with VAR bound to each car from LIST, in turn. > Then evaluate RESULT to get return value, default nil. > \(fn (VAR LIST [RESULT]) BODY...)" > (declare (indent 1) (debug ((symbolp form &optional form) body))) > (let ((temp (make-symbol "--dolist-temp--"))) > `(let ((,temp ,(nth 1 spec)) > ,(car spec)) > (while ,temp > (setq ,(car spec) (car ,temp)) > (setq ,temp (cdr ,temp)) > ,@body) > ,@(if (cdr (cdr spec)) > `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) > In the above definition, `(setq ,temp (cdr ,temp))' is not placed at > the end of the loop body, so it disables the following optimization in > byte-opt.el: > ;; X: varref-Y ... varset-Y goto-X --> > ;; X: varref-Y Z: ... dup varset-Y goto-Z > ;; (varset-X goto-BACK, BACK: varref-X --> copy the varref down.) > ;; (This is so usual for while loops that it is worth handling). > Is it OK to place `(setq ...)' after `,@body' as in the CL-version? The setq can be placed after, but the cdr can't, in case the `body' does a setcdr on it. So maybe (defmacro dolist (spec &rest body) "Loop over a list. Evaluate BODY with VAR bound to each car from LIST, in turn. Then evaluate RESULT to get return value, default nil. \(fn (VAR LIST [RESULT]) BODY...)" (declare (indent 1) (debug ((symbolp form &optional form) body))) (let ((temp (make-symbol "--dolist-temp--"))) `(let ((,temp ,(nth 1 spec)) ,(car spec)) (while ,temp (setq ,(car spec) (car ,temp)) (setq ,temp (prog1 (cdr ,temp) ,@body))) ,@(if (cdr (cdr spec)) `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) will do the trick? Stefan