[webkit-dev] MessagePorts and garbage collection
atwilson at google.com
Thu May 7 12:29:04 PDT 2009
BTW, it looks like the current Worker implementation doesn't notify the
Worker object when timers/network activity are finished, so an unreferenced
Worker thread won't be terminated in that case. When I get done with this
design mess, I'll log a bug with some tests.
On Thu, May 7, 2009 at 11:54 AM, Alexey Proskuryakov <ap at webkit.org> wrote:
> on 07.05.2009 22:25, Maciej Stachowiak at mjs at apple.com wrote:
> > The best way I can think of to handle this is to have a special phase
> > normal marking where objects with an external/cross-thread reference get
> > marked in a distinctive way. Then each MessagePort would know if it was
> > solely due to its opposite endpoint being live. I don't recall if there
> is a
> > way for an unreachable MessagePort to become reachable - I think yes,
> > the message event listener can stuff the MessagePort in a global
> variable. But
> > I think an unerachable port can only become reachable by receiving a
> > Thus, you need a core data structure for the MessageChannel which detects
> > case that there are no messages pending in either direct and both
> > are alive only due to the other endpoint. Something like that. This is a
> > rough design sketch, Alexey can probably explain in more detail or I can
> > the code.
> This design with a separate stage between marking and sweeping is something
> that I started implementing, and had in ToT for a while last year. As I
> recall, the big problem with it is the need to detect when there are no
> messages pending in either direction, which is not possible without
> temporarily freezing the other thread/process AFAICT. That's something I'd
> like to avoid (yes, we do have a lock in MessageQueue, but it's not
> necessary long-term, and there are already reports that it seriously
> > My impression is that Workers use a similar scheme with a special
> > marking phase, or once did, but Alexey will recall better than I.
> You are probably thinking about my attempts to implement cross-thread
> MessagePort here. Worker GC makes use of the ActiveDOMObject concept - for
> as long as there is an unanswered message, or if it is known that the
> thread has timers (or network requests) running in it, the Worker object in
> main thread is deemed uncollectable. So, dedicated workers did not require
> - WBR, Alexey Proskuryakov.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev