[Webkit-unassigned] [Bug 204871] New: sched_yield can cause calling thread to be preempted for 10 ms on Darwin

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 4 20:07:20 PST 2019


https://bugs.webkit.org/show_bug.cgi?id=204871

            Bug ID: 204871
           Summary: sched_yield can cause calling thread to be preempted
                    for 10 ms on Darwin
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Template Framework
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: nham at apple.com

We currently use sched_yield in both bmalloc and WTF::Lock. This can lead to the calling thread being preempted for up to 10 ms even if the lock was relinquished much earlier than that because of the way this is implemented on Darwin:

 - sched_yield calls the swtch_pri syscall
 - swtch_pri depresses the calling thread's priority to 0 for thread_depress_time milliseconds
 - thread_depress_time is set to one scheduling quantum in sched_*.c
 - most of our devices run with a timer tick of 10 ms, so thread_depress_time is 10 ms
 - if the system is busy with enough >0 pri work for 10 ms to saturate all possible CPUs, then the calling thread blocks for 10 ms

We actually see exactly this in a number of MobileSafari launch tests (this originally came up as a launch test variability issue from the perf team).

An alternative is to use thread_switch, which can depress the priority of the calling thread for a configurable amount of time with millisecond granularity.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20191205/b069ed28/attachment.htm>


More information about the webkit-unassigned mailing list