0.9.8.18:
authorJuho Snellman <jsnell@iki.fi>
Sat, 7 Jan 2006 18:22:58 +0000 (18:22 +0000)
committerJuho Snellman <jsnell@iki.fi>
Sat, 7 Jan 2006 18:22:58 +0000 (18:22 +0000)
        Rearrange the GENCGC "struct page" a bit to for a more compact
        memory representation. Saves memory (about 15MB on x86-64
        where the page table is large, a couple of MB on x86). Also
        a minor performance improvement thanks to cache issues.

        TODO: The size could be still improved by another 15MB on x86-64
        by defining the ill-named first_object_offset as an int
        instead of long (4 bytes less data and 4 bytes less of padding).
        The naive implementation would then limit the maximum region size
        to 4GB. Since some low bits in the field are guaranteed to be
        zero, a smart implementation could do some shifts and store even
        more data. It remains to be seen whether this would be worthwhile.

src/code/room.lisp
src/runtime/gc.h
src/runtime/gencgc-internal.h
version.lisp-expr

index 31e6275..ea2f309 100644 (file)
 ;;; MAP-ALLOCATED-OBJECTS
 #!+gencgc
 (progn
-  (define-alien-type nil
+  (define-alien-type (struct page)
       (struct page
-              (flags unsigned-int)
-              (gen int)
-              (bytes-used int)
-              (start long)))
+              (start long)
+              (bytes-used (unsigned 16))
+              (flags (unsigned 8))
+              (gen (signed 8))))
   (declaim (inline find-page-index))
   (define-alien-routine "find_page_index" long (index long))
   (define-alien-variable "page_table"
                             ;; bitfields?
                             (let ((alloc-flag (ldb (byte 3 2)
                                                    (slot page 'flags)))
-                                   (bytes-used (slot page 'bytes-used)))
+                                  (bytes-used (slot page 'bytes-used)))
                               ;; If the page is not free and the current
                               ;; pointer is still below the allocation offset
                               ;; of the page
index 5209583..90e94bf 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef _GC_H_
 #define _GC_H_
 typedef signed long page_index_t;
-typedef signed int generation_index_t;
+typedef signed char generation_index_t;
 
 extern void gc_init(void);
 extern void gc_initialize_pointers(void);
index c7fb5c5..b2d2f25 100644 (file)
@@ -32,8 +32,28 @@ inline void *page_address(page_index_t);
 int gencgc_handle_wp_violation(void *);
 \f
 struct page {
+    /* The name of this field is not well-chosen for its actual use.
+     * This is the offset from the start of the page to the start
+     * of the alloc_region which contains/contained it.  It's negative or 0
+     */
+    long  first_object_offset;
+
+    /* the number of bytes of this page that are used. This may be less
+     * than the actual bytes used for pages within the current
+     * allocation regions. It should be 0 for all unallocated pages (not
+     * hard to achieve).
+     *
+     * Currently declared as an unsigned short to make the struct size
+     * smaller. This means that GENCGC-PAGE-SIZE is constrained to fit
+     * inside a short.
+     */
+    unsigned short bytes_used;
+
+#if USHRT_MAX < PAGE_BYTES
+#error "PAGE_BYTES too large"
+#endif
 
-    unsigned int
+    unsigned
         /* This is set when the page is write-protected. This should
          * always reflect the actual write_protect status of a page.
          * (If the page is written into, we catch the exception, make
@@ -62,20 +82,9 @@ struct page {
      * allocation region pages - this allows the space of an object to
      * be easily determined. */
     generation_index_t gen;
-
-    /* the number of bytes of this page that are used. This may be less
-     * than the actual bytes used for pages within the current
-     * allocation regions. It should be 0 for all unallocated pages (not
-     * hard to achieve). */
-    int  bytes_used;
-
-    /* The name of this field is not well-chosen for its actual use.
-     * This is the offset from the start of the page to the start
-     * of the alloc_region which contains/contained it.  It's negative or 0
-     */
-    long  first_object_offset;
 };
 
+
 /* values for the page.allocated field */
 
 \f
index 20592f2..80c7db2 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.8.17"
+"0.9.8.18"