<div dir="ltr"><div>Interesting point. I don't think there are any large objects with SRTs, but we should document the invariant because we're relying on it.</div><div><br></div><div>Large objects can only be primitive objects, like MUT_ARR_PTRS, allocated by the RTS, and none of these have SRTs.</div><div><br></div><div>We did have plans to allocate memory for large dynamic objects using `allocate()` from compiled code, in which case we could have large objects that could be THUNK, FUN, etc. and could have an SRT, in which case we would need to revisit this.  You might want to take a look at Note [big objects] in GCUtils.c, which is relevant here.</div><div><br></div><div>Cheers</div><div>Simon<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 20 June 2018 at 09:20, Ömer Sinan Ağacan <span dir="ltr"><<a href="mailto:omeragacan@gmail.com" target="_blank">omeragacan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Simon,<br>
<br>
I'm confused about this code again. You said<br>
<span class=""><br>
> scavenge_one() is only used for a non-major collection, where we aren't<br>
> traversing SRTs.<br>
<br>
</span>But I think this is not true; scavenge_one() is also used to scavenge large<br>
objects (in scavenge_large()), which are scavenged even in major GCs. So it<br>
seems like we never really scavenge SRTs of large objects. This doesn't look<br>
right to me. Am I missing anything? Can large objects not refer to static<br>
objects?<br>
<br>
Thanks<br>
<br>
Ömer<br>
<br>
Ömer Sinan Ağacan <<a href="mailto:omeragacan@gmail.com">omeragacan@gmail.com</a>>, 2 May 2018 Çar, 09:03<br>
tarihinde şunu yazdı:<br>
<div class="HOEnZb"><div class="h5">><br>
> Thanks Simon, this is really helpful.<br>
><br>
> > If you look at scavenge_fun_srt() and co, you'll see that they return<br>
> > immediately if !major_gc.<br>
><br>
> Thanks for pointing this out -- I didn't realize it's returning early when<br>
> !major_gc and this caused a lot of confusion. Now everything makes sense.<br>
><br>
> I'll add a note for scavenging SRTs and refer to it in relevant code and submit<br>
> a diff.<br>
><br>
> Ömer<br>
><br>
> 2018-05-01 22:10 GMT+03:00 Simon Marlow <<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>>:<br>
> > Your explanation is basically right. scavenge_one() is only used for a<br>
> > non-major collection, where we aren't traversing SRTs. Admittedly this is a<br>
> > subtle point that could almost certainly be documented better, I probably<br>
> > just overlooked it.<br>
> ><br>
> > More inline:<br>
> ><br>
> > On 1 May 2018 at 10:26, Ömer Sinan Ağacan <<a href="mailto:omeragacan@gmail.com">omeragacan@gmail.com</a>> wrote:<br>
> >><br>
> >> I have an idea but it doesn't explain everything;<br>
> >><br>
> >> SRTs are used to collect CAFs, and CAFs are always added to the oldest<br>
> >> generation's mut_list when allocated [1].<br>
> >><br>
> >> When we're scavenging a mut_list we know we're not doing a major GC, and<br>
> >> because mut_list of oldest generation has all the newly allocated CAFs,<br>
> >> which<br>
> >> will be scavenged anyway, no need to scavenge SRTs for those.<br>
> >><br>
> >> Also, static objects are always evacuated to the oldest gen [2], so any<br>
> >> CAFs<br>
> >> that are alive but not in the mut_list of the oldest gen will stay alive<br>
> >> after<br>
> >> a non-major GC, again no need to scavenge SRTs to keep these alive.<br>
> >><br>
> >> This also explains why it's OK to not collect static objects (and not<br>
> >> treat<br>
> >> them as roots) in non-major GCs.<br>
> >><br>
> >> However this doesn't explain<br>
> >><br>
> >> - Why it's OK to scavenge large objects with scavenge_one().<br>
> ><br>
> ><br>
> > I don't understand - perhaps you could elaborate on why you think it might<br>
> > not be OK? Large objects are treated exactly the same as small objects with<br>
> > respect to their lifetimes.<br>
> ><br>
> >><br>
> >> - Why we scavenge SRTs in non-major collections in other places (e.g.<br>
> >>   scavenge_block()).<br>
> ><br>
> ><br>
> > If you look at scavenge_fun_srt() and co, you'll see that they return<br>
> > immediately if !major_gc.<br>
> ><br>
> >><br>
> >> Simon, could you say a few words about this?<br>
> ><br>
> ><br>
> > Was that enough words? I have more if necessary :)<br>
> ><br>
> > Cheers<br>
> > Simon<br>
> ><br>
> ><br>
> >><br>
> >><br>
> >> [1]: <a href="https://github.com/ghc/ghc/blob/master/rts/sm/Storage.c#L445-L449" rel="noreferrer" target="_blank">https://github.com/ghc/ghc/<wbr>blob/master/rts/sm/Storage.c#<wbr>L445-L449</a><br>
> >> [2]: <a href="https://github.com/ghc/ghc/blob/master/rts/sm/Scav.c#L1761-L1763" rel="noreferrer" target="_blank">https://github.com/ghc/ghc/<wbr>blob/master/rts/sm/Scav.c#<wbr>L1761-L1763</a><br>
> >><br>
> >> Ömer<br>
> >><br>
> >> 2018-03-28 17:49 GMT+03:00 Ben Gamari <<a href="mailto:ben@well-typed.com">ben@well-typed.com</a>>:<br>
> >> > Hi Simon,<br>
> >> ><br>
> >> > I'm a bit confused by scavenge_one; namely it doesn't scavenge SRTs. It<br>
> >> > appears that it is primarily used for remembered set entries but it's<br>
> >> > not at all clear why this means that we can safely ignore SRTs (e.g. in<br>
> >> > the FUN and THUNK cases).<br>
> >> ><br>
> >> > Can you shed some light on this?<br>
> >> ><br>
> >> > Cheers,<br>
> >> ><br>
> >> > - Ben<br>
> >> ><br>
> >> > ______________________________<wbr>_________________<br>
> >> > ghc-devs mailing list<br>
> >> > <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> >> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
> >> ><br>
> >> ______________________________<wbr>_________________<br>
> >> ghc-devs mailing list<br>
> >> <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> >> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
> ><br>
> ><br>
</div></div></blockquote></div><br></div>