Skip to content

Commit

Permalink
0.9.8.18:
Browse files Browse the repository at this point in the history
        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.
  • Loading branch information
jsnell committed Jan 7, 2006
1 parent 8c685e1 commit fd225cf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/code/room.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@
;;; 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"
Expand Down Expand Up @@ -265,7 +265,7 @@
;; 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
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
35 changes: 22 additions & 13 deletions src/runtime/gencgc-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,28 @@ inline void *page_address(page_index_t);
int gencgc_handle_wp_violation(void *);

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
Expand Down Expand Up @@ -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 */


Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit fd225cf

Please sign in to comment.