emacs-devel
[Top][All Lists]
Advanced

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

Re: Building Emacs overflowed pure space


From: Stefan Monnier
Subject: Re: Building Emacs overflowed pure space
Date: Tue, 18 Jul 2006 16:56:36 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> I don't think it's reasonable at this stage.  We are not supposed to
> install changes that increase the pure size significantly; adding 10K
> will just risk wasting memory in the released Emacs.

I'm not sure what size other people get, but my `emacs' binary is never
smaller than 2MB (by a long shot), so even if one counts the worst case
20KB of wasted space (10KB * 2 (64bit growth factor)), it's still less than
1%.  Not much to worry about.  If we really care about that kind of memory,
we can do as XEmacs did: dump once to see how much pure space is necessary,
than adjust pure size and redump.

I use here a local hack which saves more pure space than that by simply
using a more compact representation for strings.  I haven't installed it
because I'm not convinced it's worth the trouble (it's more interesting on
64bit systems, tho).  See patch hunk below to get a feel for it ;-)


        Stefan


--- orig/src/lisp.h
+++ mod/src/lisp.h
@@ -709,14 +736,24 @@
 /* Set text properties.  */
 #define STRING_SET_INTERVALS(STR, INT) (XSTRING (STR)->intervals = (INT))
 
+/* If the string's size is smaller than the size of a pointer,
+   we store the data directly in Lisp_String, otherwise, we store it in
+   a separate object.  */
+#define STRING_MAXINLINE (sizeof (unsigned char *))
+
 /* In a string or vector, the sign bit of the `size' is the gc mark bit */
 
 struct Lisp_String
   {
     EMACS_INT size;
-    EMACS_INT size_byte;
+    EMACS_INT size_byte : BITS_PER_EMACS_INT - 1;
+    unsigned inlined : 1;      /* 0 -> ptr, 1 -> chars; in union below.  */
     INTERVAL intervals;                /* text properties in this string */
-    unsigned char *data;
+    union
+    { 
+      unsigned char *ptr;
+      unsigned char chars[STRING_MAXINLINE];
+    } data;
   };
 
 #ifdef offsetof




reply via email to

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