[Vm-dev] Where is the heap?

John McIntosh johnmci at smalltalkconsulting.com
Wed May 12 06:25:20 UTC 2010

Ok, well there is a number of optimizations on the os-x and iphone VM code
that I should explain. I choose 500M as a start value because then I can
save an image with an os-x based VM and move it to the iPhone without having
the oops pointer logic wanting to reset all the oops offset values, ie if
the saved start of memory is the same as the new start of memory then we
skip the oops reset.

On the iPhone the mmap logic  maps ram memory to the flash memory pages of
the image, so if you don't touch the ram then it doesn't swap the page from
flash into ram.  So if you avoid doing the oops pointer reset, and the dozen
or so allInstances that occur that at image startup time, then you avoid 2
or 3 seconds of clock time that was taken to swap in oops pages from flash
to ram (for no purpose).  This could be fixed if you could create images
that only contain objects that are actually used, but that problem is hard
to solve.

For the iPhone I could make the image file mmap writable, but by design
image files are read-only, although I could make a writable copy, but was
unsure of issues of crashes and what state the image file would be in. Well
I could set a flag, but this issue is less important now from the days when
an iphone had only about 64MB of ram to work with, versus the 150MB in an
iphone 3GS. Still I might revisit this since it technically provides virtual
memory backing to storage (flash) if ram becomes constraint.

For os-x and the iphone if you look closer I did mmap the image file bytes
into space starting at 500MB, but then I mmaped anonymous memory after the
end of the image file to the upper limit. That works quite well on the
iphone and on testing on an older powerbook 3400 showed an interesting
time/work curves as it pages in the oops pages, but we discovered that this
particular setup does not properly work on NFS mounted volumes so the logic
is turned off on os-x. Although there is a flag to enable it if you wish to
shave a few 100ms off the os-x vm startup time. Otherwise on os-x we just
dump the image file data into mmap memory via an fread() Yes mmap was faster
(but faulty), and on os-x it would (unlike iphone) swap in all the image
file pages at once.

On Tue, May 11, 2010 at 10:54 PM, Javier Pimás
<elpochodelagente at gmail.com>wrote:

> The heap is at a virtual address that depends on the platform. Many
> platforms try to put it starting at a fixed virtual address (like 500M or
> 512M). Unix doesn't bother.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100511/907b9a6a/attachment.htm

More information about the Vm-dev mailing list