emacs-devel
[Top][All Lists]
Advanced

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

Re: malloc and alignment


From: Stefan Monnier
Subject: Re: malloc and alignment
Date: Mon, 16 Jun 2003 11:39:44 -0400

> > I'd like to try and get rid of the markbit on Lisp_Object values.
> > The idea is to scrape off a few more bits (I'd like to bump maxint
> > to 512MB instead of 128MB).  And I'd also like to represent floats
> > in 8bytes rather than 12.
> 
> If you are scraping off bits, why not instead _add_ one, but reserve
> _all_ the additional tag values gained in that way for representing
> integers?
> 
> Something like "tag byte values of 0 to 127 all represent integers,
> tag byte values from 128 to 256 represent all other data types".
> 
> That way integers would go up to 1GB without pain.

We already eat 4bits of each pointer (and what's worse, we eat the topmost
ones, and leave the unused 2 (or 3) lower bits untouched).  If we eat more
we'll bump even more quickly into the problem where Emacs can't allocate
any more data because it has eaten up its address space (which is
currently only 256MB large and would be reduce accordingly).

We try to minimize the problem by allocating buffer-text separately,
so buffer-text shouldn't eat into this address space, but it is still
an important limitation (buffers eat up memory not only in terms
of buffer-text but also things like text-properties, ...).

Instead, I'd like to reduce those 4bits down to 3 (it's currently 3bits
of tag plus one bit of marking, so removing the markbit will bring it
down to 3) and maybe also make use of the 4-byte alignment of objects
so we don't waste the lower 2bits (we can just shift the pointer by
2bits before adding our 3bits tag, so we only eat up the top bit.
Or we can even impose an 8byte alignment, don't eat any pointer
space at all, and just place the tag on the lower bits).
Anyway, experimentation is needed first.


        Stefan "who always wished that 64bit architectures would use
                bit-addressing rather than byte-addressing, such that
                a natural 64bit alignment gives you 6 bits of tag
                space to play with"


PS: The only reason why the markbit exists is because cons cells
    are made of 2 words only (not extra header), so when we mark them,
    we use one of the bits of the `car', but since any value can be
    in the `car', that means that this bit of a Lisp_Object value
    cannot be used for anything else.  The markbit is not used
    to mark the Lisp_Object referenced, but to mark the object in which
    the Lisp_Object value is placed.
PPS: I.e. in order to get rid of this mark-bit, we only need markbit bitmaps
    for cons-cells.  But I also want to use them for floats in order to have
    a more efficient representation of floats (they are currently represented
    as a 64bit double plus a one-word header of which only one bit is used).





reply via email to

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