Re: [RFC/PATCH 2/3] small-alloc: add allocator for small objects
- From
David Barr <davidbarr@google.com>
- Date
- Jun 24, 2011, 17:02 UTC
- Message-ID
- <BANLkTi=1NhVHMScynVFWxQo2H_mAGq0t1Q@mail.gmail.com>
- In-Reply-To
- <BANLkTi=34cQvU9oE0gPe=5PFDYfhxoYF+A@mail.gmail.com>
Junio wrote:
Show 7 quoted lines
> Instead of having two independently depleted byte-buffer (space[] and > len[]), I wonder if it would be more space efficient (without being less > processing efficient) to use a single buffer space. Your pool_ptr() would > start at the beginning of pool->space[n], decode a varint and take it as a > length, if that is not the object you are looking for, skip that many > bytes (i.e. payload immediately follows the length) to the next object, > and so on.
David Barr wrote:
Show 6 quoted lines
> I have already investigated this arrangement, it has very poor > locality of access. > For objects <32 bytes long, its not too bad since typically 2 bytes of a 64 byte > cache line would be read consecutively. For larger objects this is pathological > cache behavior. On the other hand, the current design means that the entire > sequence of lengths will fit on a single >=16 byte cache line.
Another approach is to keep the buffers separate but interleave pointers and lengths. I'll give this a go and see if it's an overall improvement.
-- David Barr