[Vm-dev] free-chunk-management-in-the-cog-vm

Ben Coman btc at openinworld.com
Sun Jun 17 23:11:05 UTC 2018

Hi Clement,

Nice article...

A random thought, I wonder if size-1 chunks can be managed packed into
size-2 chunks.

Have a variable size1_active_double initially nil.
First size-1 allocation, grab a size-2 chunk into size1_active_double.
First half returned as the size-1-chunk. Second half marked at "empty".

Second size-1 allocation, return second half of size1_active_double
as size-1-chunk.  Set  size1_active_double to nil.

Releasing a size-1-chunk. Dependent on whether memory alignment can inform
of which half of size-2-chunk is being released. Check if other half is
empty ==> add it to the size-2-chunk-list.

If other half not empty, add it to one of two singly-linked-lists depending
on which half is empty, the empty half used for the linked-list.  Next
size-1 allocations made from these lists first to fill in the empty half.

* Added complexity
* Remaining size-1 singly-linked-list might have minimal impact - added
complexity not worth the gain.

Or another random thought *grin* - and this is probably completely off base
because of my limited understanding.
Piggyback the size-1-chunk management on top of the size-3-chunk-list.
Consider one end of the size-3-chunk-list to be "size1-filled-end" with
references to free size-1-chunks, and the other end of the
size-3-chunk-list to be "size1-empty-end".

To release a size-1-chunk, move a size-3-chunk from the "size1-empty-end"
to the "size1-filled-end" and store the size-1-chunk reference there.

To allocate a size-1-chunk, get it from the "size1-filled" end of the
size-3-chunk-list and move that size-3-chunk to the "size1-empty-end" of
its list.

To compact a size-3-chunk that refers to a size-1-chunk, copy that into
another chunk from the size1-empty-end moved to the size1-filled-end.

I wonder if that even makes sense.
Anyway, it hurts less to let the ideas roam free...

cheers -ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20180618/b154f283/attachment-0001.html>

More information about the Vm-dev mailing list