MPS issue job003797

TitleAMC space is lost to pinning
Statusopen
Priorityoptional
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionWhen an AMC segment is pinned by an ambiguous reference, the pinned objects remain in the segment, but reclaimed objects are replaced with padding. This space (which might be considerable) does not get reused until the ambiguous reference goes away (if it ever does).

This leads to complication of the code, as AMC has to contain "large segment" logic to defend against a large segment being pinned down by a small pinned object with an unacceptable waste of space.

It also means that AMC can't hand out larger buffers (it is too risky as they are likely to be pinned down).
AnalysisSolve this by separating the concerns of buffering and pinning. When a pinned segment is reclaimed, add the free space in the segment to a free list structure. When handing out a buffer, hand out a range on the free list if there's one that's big enough.

Scanning a pinned segment must avoid the unused part of the buffer (scan up to buffer->init, scan from buffer->limit onwards) because that doesn't contain scannable objects.

In order for emergency collection to work, it's important that the free list structure be able to cope when there's no memory available. One idea is to fall back to storing the free ranges in the form of padding objects. This would require the object format to provide an ispad method so that we could find them again when flushing them back to the CBS or whatever, and that would lead to backwards-compatibility problems. (But, crazy idea: why not store the free ranges in the form of forwarding objects that forward to some special value! The client already provides an isfwd method.)
How foundinspection
EvidenceMPS strategy discussion <https://info.ravenbrook.com/mail/2014/05/15/19-19-13/0/>
Created byGareth Rees
Created on2014-05-15 19:25:12
Last modified byGareth Rees
Last modified on2014-05-16 10:00:14
History2014-05-15 GDR Created.