⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244233 in webkit


Ignore:
Timestamp:
Apr 12, 2019, 4:26:43 PM (7 years ago)
Author:
sbarati@apple.com
Message:

Sometimes we need to user fewer CPUs in our threading calculations
https://bugs.webkit.org/show_bug.cgi?id=196794
<rdar://problem/49389497>

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • assembler/CPU.cpp: Added.

(JSC::isKernTCSMAvailable):
(JSC::enableKernTCSM):
(JSC::kernTCSMAwareNumberOfProcessorCores):

  • assembler/CPU.h:

(JSC::isKernTCSMAvailable):
(JSC::enableKernTCSM):
(JSC::kernTCSMAwareNumberOfProcessorCores):

  • heap/MachineStackMarker.h:

(JSC::MachineThreads::addCurrentThread):

  • runtime/JSLock.cpp:

(JSC::JSLock::didAcquireLock):

  • runtime/Options.cpp:

(JSC::computeNumberOfWorkerThreads):
(JSC::computePriorityDeltaOfWorkerThreads):

  • wasm/WasmWorklist.cpp:

(JSC::Wasm::Worklist::Worklist):

Source/WebKit:

  • WebProcess/com.apple.WebProcess.sb.in:
Location:
trunk/Source
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r244222 r244233  
     12019-04-12  Saam barati  <sbarati@apple.com>
     2
     3        Sometimes we need to user fewer CPUs in our threading calculations
     4        https://bugs.webkit.org/show_bug.cgi?id=196794
     5        <rdar://problem/49389497>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * JavaScriptCore.xcodeproj/project.pbxproj:
     10        * Sources.txt:
     11        * assembler/CPU.cpp: Added.
     12        (JSC::isKernTCSMAvailable):
     13        (JSC::enableKernTCSM):
     14        (JSC::kernTCSMAwareNumberOfProcessorCores):
     15        * assembler/CPU.h:
     16        (JSC::isKernTCSMAvailable):
     17        (JSC::enableKernTCSM):
     18        (JSC::kernTCSMAwareNumberOfProcessorCores):
     19        * heap/MachineStackMarker.h:
     20        (JSC::MachineThreads::addCurrentThread):
     21        * runtime/JSLock.cpp:
     22        (JSC::JSLock::didAcquireLock):
     23        * runtime/Options.cpp:
     24        (JSC::computeNumberOfWorkerThreads):
     25        (JSC::computePriorityDeltaOfWorkerThreads):
     26        * wasm/WasmWorklist.cpp:
     27        (JSC::Wasm::Worklist::Worklist):
     28
    1292019-04-12  Robin Morisset  <rmorisset@apple.com>
    230
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r244143 r244233  
    33933393                521322431ECBCE8200F65615 /* WebAssemblyFunctionBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyFunctionBase.cpp; path = js/WebAssemblyFunctionBase.cpp; sourceTree = "<group>"; };
    33943394                521322441ECBCE8200F65615 /* WebAssemblyFunctionBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyFunctionBase.h; path = js/WebAssemblyFunctionBase.h; sourceTree = "<group>"; };
     3395                52335628225EB8E900268BD2 /* CPU.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPU.cpp; sourceTree = "<group>"; };
    33953396                523FD88C225566C3003B3DCC /* WebAssemblyFunctionHeapCellType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebAssemblyFunctionHeapCellType.h; path = js/WebAssemblyFunctionHeapCellType.h; sourceTree = "<group>"; };
    33963397                523FD88D225566C4003B3DCC /* WebAssemblyFunctionHeapCellType.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyFunctionHeapCellType.cpp; path = js/WebAssemblyFunctionHeapCellType.cpp; sourceTree = "<group>"; };
     
    77997800                                86E116B00FE75AC800B512BC /* CodeLocation.h */,
    78007801                                0F30D7BF1D95D62F0053089D /* CPU.h */,
     7802                                52335628225EB8E900268BD2 /* CPU.cpp */,
    78017803                                0F37308E1C0CD68500052BFA /* DisallowMacroScratchRegisterUsage.h */,
    78027804                                0FF4275615914A20004CB9FF /* LinkBuffer.cpp */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r244143 r244233  
    4444
    4545assembler/AbstractMacroAssembler.cpp
     46assembler/CPU.cpp
    4647assembler/LinkBuffer.cpp
    4748assembler/MacroAssembler.cpp
  • trunk/Source/JavaScriptCore/assembler/CPU.h

    r237173 r244233  
    2727
    2828#include "Options.h"
     29#include <wtf/NumberOfCores.h>
    2930
    3031namespace JSC {
     
    132133}
    133134
     135#if (CPU(X86) || CPU(X86_64)) && OS(DARWIN)
     136bool isKernTCSMAvailable();
     137bool enableKernTCSM();
     138int kernTCSMAwareNumberOfProcessorCores();
     139#else
     140ALWAYS_INLINE bool isKernTCSMAvailable() { return false; }
     141ALWAYS_INLINE bool enableKernTCSM() { return false; }
     142ALWAYS_INLINE int kernTCSMAwareNumberOfProcessorCores() { return WTF::numberOfProcessorCores(); }
     143#endif
     144
    134145} // namespace JSC
    135146
  • trunk/Source/JavaScriptCore/heap/MachineStackMarker.h

    r231158 r244233  
    4949
    5050    // Only needs to be called by clients that can use the same heap from multiple threads.
    51     void addCurrentThread() { m_threadGroup->addCurrentThread(); }
     51    bool addCurrentThread() { return m_threadGroup->addCurrentThread() == ThreadGroupAddResult::NewlyAdded; }
    5252
    5353    WordLock& getLock() { return m_threadGroup->getLock(); }
  • trunk/Source/JavaScriptCore/runtime/JSLock.cpp

    r243312 r244233  
    149149    m_vm->setStackPointerAtVMEntry(p);
    150150
    151     m_vm->heap.machineThreads().addCurrentThread();
     151    if (m_vm->heap.machineThreads().addCurrentThread()) {
     152        if (isKernTCSMAvailable())
     153            enableKernTCSM();
     154    }
     155
    152156#if ENABLE(WEBASSEMBLY)
    153157    if (Wasm::isSupported())
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r243857 r244233  
    206206static unsigned computeNumberOfWorkerThreads(int maxNumberOfWorkerThreads, int minimum = 1)
    207207{
    208     int cpusToUse = std::min(WTF::numberOfProcessorCores(), maxNumberOfWorkerThreads);
     208    int cpusToUse = std::min(kernTCSMAwareNumberOfProcessorCores(), maxNumberOfWorkerThreads);
    209209
    210210    // Be paranoid, it is the OS we're dealing with, after all.
     
    215215static int32_t computePriorityDeltaOfWorkerThreads(int32_t twoCorePriorityDelta, int32_t multiCorePriorityDelta)
    216216{
    217     if (WTF::numberOfProcessorCores() <= 2)
     217    if (kernTCSMAwareNumberOfProcessorCores() <= 2)
    218218        return twoCorePriorityDelta;
    219219
  • trunk/Source/JavaScriptCore/wasm/WasmWorklist.cpp

    r241610 r244233  
    2929#if ENABLE(WEBASSEMBLY)
    3030
     31#include "CPU.h"
    3132#include "WasmPlan.h"
    32 
    33 #include <wtf/NumberOfCores.h>
    3433
    3534namespace JSC { namespace Wasm {
     
    208207    , m_planEnqueued(AutomaticThreadCondition::create())
    209208{
    210     unsigned numberOfCompilationThreads = Options::useConcurrentJIT() ? WTF::numberOfProcessorCores() : 1;
     209    unsigned numberOfCompilationThreads = Options::useConcurrentJIT() ? kernTCSMAwareNumberOfProcessorCores() : 1;
    211210    m_threads.reserveCapacity(numberOfCompilationThreads);
    212211    LockHolder locker(*m_lock);
  • trunk/Source/WebKit/ChangeLog

    r244230 r244233  
     12019-04-12  Saam barati  <sbarati@apple.com>
     2
     3        Sometimes we need to user fewer CPUs in our threading calculations
     4        https://bugs.webkit.org/show_bug.cgi?id=196794
     5        <rdar://problem/49389497>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * WebProcess/com.apple.WebProcess.sb.in:
     10
    1112019-04-12  Devin Rousso  <drousso@apple.com>
    212
  • trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in

    r243916 r244233  
    173173        "machdep.cpu.brand_string"
    174174        "security.mac.sandbox.sentinel"
     175        "kern.tcsm_enable"
     176        "kern.tcsm_available"
    175177        "vm.footprint_suspend")
    176178    (sysctl-name-regex #"^hw.(active|avail)cpu")
     
    182184    (sysctl-name-regex #"^net.routetable")
    183185)
     186
     187(allow sysctl-write
     188    (sysctl-name
     189        "kern.tcsm_enable"))
    184190
    185191(deny iokit-get-properties)
Note: See TracChangeset for help on using the changeset viewer.