[MLton] available ram

Stephen Weeks MLton@mlton.org
Wed, 8 Feb 2006 23:01:49 -0800


> I think a point of confusion is that
> 
>           s->ram = align (s->ramSlop * s->totalRam, s->pageSize);
> 
> is a rather poor way of estimating the available ram.  

Agreed that it is a poor estimate.  But it does have the benefit of
being simple to understand and the same across all machines.

> For systems where we use sysconf(_SC_PHYS_PAGES) to determine the
> total ram, we might well use sysconf(_SC_AVPHYS_PAGES) to determine
> the available ram.  In fact, we ought to periodically recompute
> s->ram from _SC_AVPHYS_PAGES.  I imagine that this would give
> somewhat better dynamic behavior than the current situation.

There is the accuracy problem that Henry mentioned.  And, I am wary
that the lack of predictability of such solutions is worse than the
lack of dynamic responsiveness of our simplistic approach.  The truth
is that making a GC play nice with paging is hard, as papers like the
one Wesley mentioned show.  It's better to clearly not solve the
problem, as MLton does, then to make a sometimes right, sometimes
wrong, attempt at solving it.

> We might well have an availRamSlop parameter for further
> customization.

Why would one need both ramSlop and availRamSlop?