petdance/scratch — Issue #860: Parrot underestimates memory on OS X
Author: petdance
Created: 2011-11-14 06:02:05+00:00
State: open
Labels: bug, core, Pri-normal, Sev-low

On OS X, Parrot uses the HW_PHYSMEM sysctl to determine the amount of memory on the system. Unfortunately, the value returned from it is a signed 32b integer, so we will never know if a system has more than 2GiB of RAM. The sysctl man page suggests using HW_MEMSIZE to get a full 64-bit value.
This doesn't break anything, but as-is, Rakudo spends about 60% of the time building Rakudo's core.pir in gc_gmc_mark_and_sweep, which is triggered when 10% of total memory is allocated. On my system, it would trigger literally half as often if parrot knew much RAM my laptop really had.

Of course, this is complicated by the fact that we previously changed from MEMSIZE to PHYSMEM already in SVN r49633 (git 5977674) due to build errors. Does anyone know what version of Darwin MEMSIZE was introduced in? Perhaps we should check if the HW_MEMSIZE macro exists and only use PHYSMEM if it doesn't?

Originally http://trac.parrot.org/parrot/ticket/2090