Changeset 166184 in webkit


Ignore:
Timestamp:
Mar 24, 2014, 12:25:32 PM (11 years ago)
Author:
[email protected]
Message:

Add support for thread QoS
https://bugs.webkit.org/show_bug.cgi?id=130688

Reviewed by Andreas Kling.

Source/JavaScriptCore:

  • heap/BlockAllocator.cpp:

(JSC::BlockAllocator::blockFreeingThreadStartFunc):

  • block freeing is a utility activity.

Source/WTF:

  • wtf/FastMalloc.cpp:

(WTF::TCMalloc_PageHeap::runScavengerThread):

  • block freeing is a utility activity.
  • wtf/Threading.h:
    • declaration.
  • wtf/ThreadingPthreads.cpp:

(WTF::createThreadInternal):

  • default to interactive.

(WTF::setCurrentThreadQOSUtility):

  • implementation.
  • wtf/ThreadingWin.cpp:

(WTF::setCurrentThreadQOSUtility):

  • no-op implementation.
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r166178 r166184  
     12014-03-24  Gavin Barraclough  <[email protected]>
     2
     3        Add support for thread QoS
     4        https://bugs.webkit.org/show_bug.cgi?id=130688
     5
     6        Reviewed by Andreas Kling.
     7
     8        * heap/BlockAllocator.cpp:
     9        (JSC::BlockAllocator::blockFreeingThreadStartFunc):
     10            - block freeing is a utility activity.
     11
    1122014-03-24  Filip Pizlo  <[email protected]>
    213
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp

    r163844 r166184  
    3333#include "WeakBlock.h"
    3434#include <wtf/CurrentTime.h>
     35#include <wtf/Threading.h>
    3536
    3637namespace JSC {
     
    118119void BlockAllocator::blockFreeingThreadStartFunc(void* blockAllocator)
    119120{
     121    setCurrentThreadQOSUtility();
    120122    static_cast<BlockAllocator*>(blockAllocator)->blockFreeingThreadMain();
    121123}
  • trunk/Source/WTF/ChangeLog

    r166149 r166184  
     12014-03-24  Gavin Barraclough  <[email protected]>
     2
     3        Add support for thread QoS
     4        https://bugs.webkit.org/show_bug.cgi?id=130688
     5
     6        Reviewed by Andreas Kling.
     7
     8        * wtf/FastMalloc.cpp:
     9        (WTF::TCMalloc_PageHeap::runScavengerThread):
     10            - block freeing is a utility activity.
     11        * wtf/Threading.h:
     12            - declaration.
     13        * wtf/ThreadingPthreads.cpp:
     14        (WTF::createThreadInternal):
     15            - default to interactive.
     16        (WTF::setCurrentThreadQOSUtility):
     17            - implementation.
     18        * wtf/ThreadingWin.cpp:
     19        (WTF::setCurrentThreadQOSUtility):
     20            - no-op implementation.
     21
    1222014-03-23  Hyowon Kim  <[email protected]>
    223
  • trunk/Source/WTF/wtf/FastMalloc.cpp

    r165729 r166184  
    8080#include "Assertions.h"
    8181#include "CurrentTime.h"
     82#include "Threading.h"
    8283
    8384#include <limits>
     
    20592060void* TCMalloc_PageHeap::runScavengerThread(void* context)
    20602061{
     2062    setCurrentThreadQOSUtility();
     2063
    20612064    static_cast<TCMalloc_PageHeap*>(context)->scavengerThread();
    20622065#if (COMPILER(MSVC) || COMPILER(SUNCC))
  • trunk/Source/WTF/wtf/Threading.h

    r165687 r166184  
    9090
    9191WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
     92WTF_EXPORT_PRIVATE void setCurrentThreadQOSUtility();
    9293WTF_EXPORT_PRIVATE void changeThreadPriority(ThreadIdentifier, int);
    9394WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
     
    100101using WTF::currentThread;
    101102using WTF::changeThreadPriority;
     103using WTF::setCurrentThreadQOSUtility;
    102104using WTF::detachThread;
    103105using WTF::waitForThreadCompletion;
  • trunk/Source/WTF/wtf/ThreadingPthreads.cpp

    r165691 r166184  
    174174    auto invocation = std::make_unique<ThreadFunctionInvocation>(entryPoint, data);
    175175    pthread_t threadHandle;
    176     if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get())) {
     176    pthread_attr_t attr;
     177    pthread_attr_init(&attr);
     178#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     179    pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INTERACTIVE, 0);
     180#endif
     181    int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get());
     182    pthread_attr_destroy(&attr);
     183
     184    if (error) {
    177185        LOG_ERROR("Failed to create pthread at entry point %p with data %p", wtfThreadEntryPoint, invocation.get());
    178186        return 0;
     
    226234    pthread_setschedparam(pthreadHandle, policy, &param);
    227235}
    228    
     236
     237void setCurrentThreadQOSUtility()
     238{
     239#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     240    pthread_set_qos_class_np(pthread_self(), QOS_CLASS_UTILITY, 0);
     241#endif
     242}
     243
    229244int waitForThreadCompletion(ThreadIdentifier threadID)
    230245{
  • trunk/Source/WTF/wtf/ThreadingWin.cpp

    r165687 r166184  
    256256
    257257    SetThreadPriority(threadHandle, THREAD_PRIORITY_NORMAL + delta);
     258}
     259
     260void setCurrentThreadQOSUtility()
     261{
    258262}
    259263
Note: See TracChangeset for help on using the changeset viewer.