MPS issue job003766

TitleSplitting and merging complicates writing new seg classes
Statusopen
Prioritynice
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionIt's hard to write a new seg subclass because of the splitting and merging methods. You have to ensure that whatever information you are trying to record in your subclass gets split and merged correctly, and that might be delicate or impossible.
AnalysisThe existence of SegClassMixInNoSplitMerge is a bad code smell -- subclasses should add functionality to a superclass, not remove it. So what's going on here?

In fact nearly all seg classes lack the split/merge capability. Only SegClass and GCSegClass and AMSSegClass actually implement the splitting and merging logic. All other Seg sub-classes prevent split/merge by using SegClassMixInNoSplitMerge.

Looking further, it doesn't seem as though this functionality is used anywhere other than the segsmss test case [2]. In design/seg.txt [3] there is an explanation of how it works, but it is not traceable to any requirements. Examination of the original change by Tony Mann [4] gives no clues as to why it was done. There's a clue in design/locus.txt, which says, "Non-moving pools manage fragmentation with placement strategies that use: ... segment merging and splitting." So maybe the idea was that AMS could be made generational by splitting unused parts of segments into their own segments which could be recycled to the nursery generation? If so, nothing was done about it.

So I propose removing the split/merge capability to simplify writing new seg subclasses.

GDR 2014-04-22: In discussion with DL, we found a use case for splitting segments. In order to improve performance with multiple threads, we would like to be able to use bigger buffers. But bigger buffers have a severe downside: when they are pinned by an ambiguous reference we lose the whole segment. If we could split segments then we could reclaim the parts of the buffer that have no nails.
How foundinspection
Evidence[1] <http://www.ravenbrook.com/project/mps/master/code/seg.c>
[2] <http://www.ravenbrook.com/project/mps/master/code/segsmss.c>
[3] <http://www.ravenbrook.com/project/mps/master/design/seg.txt>
[4] <https://info.ravenbrook.com/infosys/cgi/perfbrowse.cgi?%40describe+21061> and subsequent changes.
Created byGareth Rees
Created on2014-04-16 12:55:41
Last modified byGareth Rees
Last modified on2014-04-22 17:20:26
History2014-04-16 GDR Created.