Boost logo

Boost :

Subject: Re: [boost] Interest request for pointer+bit compression optimization
From: Daniel Hulme (st_at_[hidden])
Date: 2009-09-07 13:46:06


On Mon, Sep 07, 2009 at 07:00:14PM +0200, vicente.botet wrote:
> I have recently found in the blog of Joaquin the following
> optimization consisting in embed a bit into the representation of a
> pointer. Please read it, it is not too long
> (http://bannalia.blogspot.com/2008/11/optimizing-red-black-tree-color-bits.html)

One of my colleagues wrote something similar, with get and set methods
instead of proxy classes, and we use it extensively at work. On AMD64
(and whatever the Intel name for the same thing is) pointers are always
divisible by 4, so we actually store 2 bits in each pointer.

I've also written a boost::variant-like class that uses the 2 bits to
store the which() value for up to four types of pointer (one of which
can instead be boost::blank), in order to reduce the size of my small-
buffer-optimization class. We don't use this right now because code
elsewhere in the system needs to get a reference to the pointer stored
in it, and templating the whole lot so we can pass a proxy object around
is too horrific for words.

-- 
"I think you look like the Mona Lisa.  You always seem to be at a window
admiring the landscape that is actually behind you."    Herve Le Tellier
http://surreal.istic.org/                      It's like a DEATH CIRCUS!



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk