Hello,

To answer your question, V8 definitely supports memory segments. I don't know about papers but in the code each segment is an instance of Heap (see heap.cc and heap.h in the source). The 2 young spaces are in another contiguous segment of 8Mb.

Each segment of V8 are one of this kind (all instances of Heap):

 * NewSpace: New object allocations go here. Capacity is 8MB. It's divided into two contiguous semispaces, and periodically collected using Cheney's algorithm. Uses bump-allocation.
 * OldSpaces: These allocate memory in 64-128KB chunks of 8KB pages. They come in the following flavors:
   * MapSpace:     Exclusively for Maps (similar to js::Shape), and Maps *always* go here.
   * CodeSpace:    Exclusively for Code.
   * DataSpace:    For flat strings and numbers; can't reference objects, except for maps.
   * PointerSpace: For anything not a Map or Code that can reference other objects.
   * CellSpace:    Seems to store global properties or something.
 * LOSpace:  For large objects, where "large" means it needs more than ~8KB of storage.

I have no proof for hotspot (their code is too complex) but I'm sure they have it too.

For the other question (adding elements to OrderedCollection), Eliot will answer it in more details, but the main idea is that you have the heap chopped into segments of a fixed size (1Mb in Cog, and�64-128KB chunks in V8), therefore for object bigger than a segment, you need to handle specifically the object, i.e. having a segment of the size of the object. If you add 30 000 elements to an OrderedCollection, the object will still be under 1MB so it is ok, now if you a 3 million of elements to this OrderedCollection, you need to handle specifically, Therefore you have performance loss for object of more than 1Mb but there are not common so you will not notice it (you can hardly have thousands of objects bigger than 1Mb allocated and deallocated regularly, and you need this amount to notice the performance loss).

An interesting point in V8 is that the data and pointers are not in the same spaces. It would mean in Cog, if I understand correctly, that byte and word objects are not in the same space as other objects. I guess this simplifies the GC logic. I don't know if they did that in VW.


2013/11/25 Alexandre Bergel <alexandre.bergel@me.com>
Hi Eliot,

I have a question still on segmented memory.

Consider an object �c := OrderedCollection new�. It is likely that the internal "array� and the object c will be in the same generation and in the same memory segment.
If I add, let�s say, 30 000 000 elements into c. After the addition the array will be very very big. Which means that it may be in a different segment memory than the one that contains �c�. Do you feel this may be a problem? I am thinking about a long jump between c and array. Long jumps cost more than short jumps right?

Do you feel there are some suboptimal situation with this situation?

Alexandre

NB: I cc the mailing list to see whether other may help in understand better what�s going on with segment and generations
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel �http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Nov 19, 2013, at 1:37 PM, Eliot Miranda <eliot.miranda@gmail.com> wrote:

> Hi Alexandre,
>
>
> On Mon, Nov 18, 2013 at 7:40 AM, Alexandre Bergel <alexandre.bergel@me.com> wrote:
> Hi Eliot,
>
> Stef told me you are working hard on improving the Pharo VM.
> In particular making the VM support fragmented memory. If I understand correctly, this will relieve the VM from having a continuous block of memory to hold the whole image. Really cool!
>
> A better term is segmented memory. �fragmentation in memory management means free space getting divided into too small pieces to be useful.
>
> I have a general question regarding VM. Are you aware of other Virtual machines supporting this? Does the Java VM support fragmented memory? .Net? V8?
>
> Any VM that uses the train algorithm supports segmented memory. �Any VM that uses "pools" or "regions" uses segmented memory. �VisualWorks' VM supports segments. �I'm pretty sure that V8 .Net & HotSpot provide segmented memory.
>
>
> I would like to mention this in a research paper I am working on.
>
> Cheers,
> Alexandre
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel �http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>
>
>
> --
> best,
> Eliot