Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c8e9c0c0c8605b26d8225c67cd5afdf5598feb37
      
https://github.com/WebKit/WebKit/commit/c8e9c0c0c8605b26d8225c67cd5afdf5598feb37
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-09-15 (Fri, 15 Sep 2023)

  Changed paths:
    M Source/JavaScriptCore/heap/Heap.cpp
    M Source/JavaScriptCore/heap/Heap.h
    M Source/JavaScriptCore/runtime/VM.cpp
    M Source/WebCore/loader/SubframeLoader.cpp
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h

  Log Message:
  -----------
  Add support for full GC during opportunistically scheduled tasks
https://bugs.webkit.org/show_bug.cgi?id=261491
rdar://113241499

Reviewed by Yusuke Suzuki.

Add support for triggering full GC during opportunistically scheduled tasks. 
This is similar to the
previous work done for eden GC in 267893@main, only (generally) more 
restrictive:

1.  We use `m_totalBytesVisited`, `m_totalBytesVisitedAfterLastFullCollect`, 
and the duration of the
    last GC to (more accurately) estimate the cost of a full GC.

2.  We only attempt full GC here if `m_shouldDoOpportunisticFullCollection` is 
`true`; this flag is
    only set when changing the location of a subframe, which has previously 
finished loading content
    (see below for more details).

3.  Instead of a 10 ms hysteresis, we add an extended hysteresis such that we 
don't trigger
    opportunistic full GC if we've already finished a full GC in the last 30 ms.

* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::updateObjectCounts):

Keep track of `m_totalBytesVisitedAfterLastFullCollect` here (that is — 
`m_totalBytesVisited`, but
for the last full GC).

(JSC::Heap::runEndPhase):

Update the new `m_lastFullGCEndTime` alongside `m_lastGCEndTime`, only if we're 
ending a full GC
cycle.

(JSC::Heap::willStartCollection):
(JSC::Heap::updateAllocationLimits):
(JSC::Heap::scheduleOpportunisticFullCollectionIfNeeded):

Add a hook into `JSC::Heap` to set the `m_shouldDoOpportunisticFullCollection` 
flag only in the case
where `shouldDoFullCollection()` is set. See call site below in `Page`.

* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::performOpportunisticallyScheduledTasks):

Add logic to conditionally trigger full opportunistic GC. We also refactor this 
to use an inline
lambda block, so that we can make the code a bit easier to follow with early 
returns. This also
allows us to fall back to an eden GC in the case where we don't have enough 
time budget for a full
GC cycle.

* Source/WebCore/loader/SubframeLoader.cpp:
(WebCore::FrameLoader::SubframeLoader::loadOrRedirectSubframe):

Add a hook to call into `Page` when changing the location of a subframe, only 
if that subframe had
previously finished loading prior content.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::willChangeLocationInCompletelyLoadedSubframe):
* Source/WebCore/page/Page.h:

Canonical link: https://commits.webkit.org/268039@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to