[webkit-changes] [WebKit/WebKit] f6fade: Add a ProcessAssertion cache

Chris Dumez noreply at github.com
Fri Oct 13 14:56:02 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f6fade6a9e367bcee8abcd66172b043ac89c915d
      https://github.com/WebKit/WebKit/commit/f6fade6a9e367bcee8abcd66172b043ac89c915d
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-10-13 (Fri, 13 Oct 2023)

  Changed paths:
    M Source/WebKit/UIProcess/ProcessThrottler.cpp
    M Source/WebKit/UIProcess/ProcessThrottler.h

  Log Message:
  -----------
  Add a ProcessAssertion cache
https://bugs.webkit.org/show_bug.cgi?id=263096
rdar://113579564

Reviewed by Brent Fulgham.

Add a ProcessAssertion cache to avoid hammering RunningBoard when switching
quickly from one assertion type to another (e.g. background <-> foreground).
Taking RunningBoard assertions is expensive and this churn can result in high
CPU usage.

We have evidence this can happen for example when we're holding a background
assertion on the WebProcess but the client app keeps running JS in the view,
causing us to take a foreground assertion for each JS execution request.

We now keep previous assertions around for 3 seconds when switching from one
assertion type to another and we reuse them when possible.

* Source/WebKit/UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::ProcessAssertionCache::add):
(WebKit::ProcessThrottler::ProcessAssertionCache::tryTake):
(WebKit::ProcessThrottler::ProcessAssertionCache::remove):
(WebKit::ProcessThrottler::ProcessAssertionCache::CachedAssertion::CachedAssertion):
(WebKit::ProcessThrottler::ProcessAssertionCache::CachedAssertion::isValid const):
(WebKit::ProcessThrottler::ProcessAssertionCache::CachedAssertion::release):
(WebKit::ProcessThrottler::ProcessAssertionCache::CachedAssertion::entryExpired):
(WebKit::ProcessThrottler::ProcessThrottler):
(WebKit::ProcessThrottler::setThrottleState):
* Source/WebKit/UIProcess/ProcessThrottler.h:

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




More information about the webkit-changes mailing list