Contact emails
mlip...@chromium.org, har...@chromium.org, hpa...@chromium.org
Design doc/Spec
See the design document on Unified V8 & Blink Garbage Collection. The document is still work in progress.
Tracking bug: https://crbug.com/843903
The feature is not exposed to the web.
Summary
V8 currently performs wrapper tracing on full garbage collection to find objects transitively reachable through Blink’s object graph that is managed by Oilpan. The unified garbage collection replaces the wrapper tracing part on the Blink-side with doing a full Oilpan marking pass. This way a full transitive closure of live objects is computed.
See the design doc for a full description of how memory is currently reclaimed, effectively involving back-to-back V8 and Blink GCs, and how that is replaced with a single GC and marking pass with the unified GC.
See also the most-recent Blink talk [video; slides] on this topic.
Motivation
Switching to a unified garbage collection addresses the following problems of wrapper tracing:
GC scheduling: Reclaiming memory involving both V8 and Blink currently involves a ping-pong of garbage collections because objects in Blink are rooted (kept alive) by references from V8.
Back-to-back V8 and Blink garbage collections trace through the set of live objects that are part of wrapper tracing twice, i.e., a live object wrappable on the Blink side is currently visited by the V8 GC through wrapper tracing only to be visited again by Oilpan for the follow up GC. This handling is inefficient.
Defining the subset of relevant objects for wrapper tracing is based on C++ types of managed pointers: Member vs TraceWrapperMember. This requires that Blink developers know the object graph and whether edges can transitively reach V8 wrappers, which is error prone and resulted in numerous bugs. Some of these issues are not fixable with today’s architecture as they would require significantly enhancing the capabilities of the wrapper tracing infrastructure. The result are interop bugs where wrappers get prematurely collected which is hard to report, debug, and fix.
With a unified GC these problems do not exist anymore, specifically:
A unified GC computes the full transitive closure and immediately initiates reclamation (sweeping). There’s no need for another GC pass.
A single marking pass over live objects is enough to compute liveness.
Since the whole heap is visited for marking, the distinction between Member and TraceWrapperMember becomes unnecessary. The type can thus be removed and there should not be any problems with wrapper getting lost anymore.
Blink developers should be mostly positively affected by 3), as this removes manual reasoning and stack handling when dealing with wrappables (C++) and wrappers (JS).
Risks
Interoperability and Compatibility
The new architecture fixes interop issues where garbage collections prematurely collected wrappers. These issues cannot happen with a unified approach anymore as all edges (Member & TraceWrapperMember) in such unified garbage collections.
Ergonomics
n/a
Activation
n/a
Debuggability
The unified heap GC will allow DevTools to expose a snapshot containing complete information on any GC-managed object reachable from Blink and V8. This is however out of scope of the first implementation and can be added incrementally after adding the GC support.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
Link to entry on the feature dashboard
n/a
Requesting approval to ship?
No. We are sending out a PSA once this is ready for shipping. This feature is not web-exposed.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CABg10jw_7ajtcnq2CBF_ZneMdKZprf4XOEG0M0Y7cSzoWn%2BDzw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CABg10jxoTx8JUgzC7pXajZCeNLiMsqpt_dr8ef%2B5cz7D0H_rEA%40mail.gmail.com.