[webkit-changes] [WebKit/WebKit] 7213ee: Add a basic heuristic to trigger eden GC during op...

Wenson Hsieh noreply at github.com
Mon Sep 11 22:28:05 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7213ee0ad4e7bcab13c4e24665520040e7429130
      https://github.com/WebKit/WebKit/commit/7213ee0ad4e7bcab13c4e24665520040e7429130
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-09-11 (Mon, 11 Sep 2023)

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

  Log Message:
  -----------
  Add a basic heuristic to trigger eden GC during opportunistic tasks
https://bugs.webkit.org/show_bug.cgi?id=261358
rdar://115193873

Reviewed by Yusuke Suzuki and Mark Lam.

Extend opportunistically scheduled work to sometimes trigger an eden GC, as long as:
1. There are no imminently scheduled tasks (e.g. zero-delay timers, rAF).
2. The estimated time required to perform the eden GC fits well within the task deadline.

See below for more details.

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

Keep track of the prior value of `m_bytesAllocatedThisCycle`, right before embarking on the last
eden GC. We use this in `VM` to help estimate the cost of subsequent eden GC.

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

If there aren't any imminently scheduled tasks, use `m_bytesAllocatedBeforeLastEdenCollect` to
estimate the duration of the next eden GC; if this estimate is less than the time remaining until
the opportunistic task deadline (by at least 1 ms), then immediately perform an eden GC during this
opportunistic task.

For now, we get a rough estimate by computing the "time-per-byte" rate from the last eden GC, and
then compute the time needed for the next eden GC based on the current `m_bytesAllocatedThisCycle`.

* Source/JavaScriptCore/runtime/VM.h:
* Source/WebCore/page/Page.cpp:

Augment `Page` to forward some context from the opportunistic task scheduler to JSC, when performing
opportunistic work. For now, we only pass in whether or not there are imminently scheduled tasks,
but in the future, we can extend this with additional options to provide `VM`/`Heap` with the
information needed to make more granular decisions.

(WebCore::Page::performOpportunisticallyScheduledTasks):

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




More information about the webkit-changes mailing list