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

Changeset 242070 in webkit


Ignore:
Timestamp:
Feb 25, 2019, 9:37:52 PM (8 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Revert r226885 to make SlotVisitor creation lazy
​https://bugs.webkit.org/show_bug.cgi?id=195013

Reviewed by Saam Barati.

We once changed SlotVisitor creation apriori to drop the lock. Also, it turns out that SlotVisitor is memory-consuming.
We should defer SlotVisitor creation until it is actually required. This patch reverts r226885. Even with this patch,
we still hold many SlotVisitors after we execute many parallel markers at least once. But recovering the feature of
dynamically allocating SlotVisitors helps further memory optimizations in this area.

  • heap/Heap.cpp:

(JSC::Heap::Heap):
(JSC::Heap::runBeginPhase):

  • heap/Heap.h:
  • heap/HeapInlines.h:

(JSC::Heap::forEachSlotVisitor):
(JSC::Heap::numberOfSlotVisitors):

  • heap/MarkingConstraintSolver.cpp:

(JSC::MarkingConstraintSolver::didVisitSomething const):

  • heap/SlotVisitor.h:
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r242068 r242070  
     12019-02-25  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Revert r226885 to make SlotVisitor creation lazy
     4        https://bugs.webkit.org/show_bug.cgi?id=195013
     5
     6        Reviewed by Saam Barati.
     7
     8        We once changed SlotVisitor creation apriori to drop the lock. Also, it turns out that SlotVisitor is memory-consuming.
     9        We should defer SlotVisitor creation until it is actually required. This patch reverts r226885. Even with this patch,
     10        we still hold many SlotVisitors after we execute many parallel markers at least once. But recovering the feature of
     11        dynamically allocating SlotVisitors helps further memory optimizations in this area.
     12
     13        * heap/Heap.cpp:
     14        (JSC::Heap::Heap):
     15        (JSC::Heap::runBeginPhase):
     16        * heap/Heap.h:
     17        * heap/HeapInlines.h:
     18        (JSC::Heap::forEachSlotVisitor):
     19        (JSC::Heap::numberOfSlotVisitors):
     20        * heap/MarkingConstraintSolver.cpp:
     21        (JSC::MarkingConstraintSolver::didVisitSomething const):
     22        * heap/SlotVisitor.h:
     23
    1242019-02-25  Saam Barati  <sbarati@apple.com>
    225
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r241927 r242070  
    301301{
    302302    m_worldState.store(0);
    303 
    304     for (unsigned i = 0, numberOfParallelThreads = heapHelperPool().numberOfThreads(); i < numberOfParallelThreads; ++i) {
    305         std::unique_ptr<SlotVisitor> visitor = std::make_unique<SlotVisitor>(*this, toCString("P", i + 1));
    306         if (Options::optimizeParallelSlotVisitorsForStoppedMutator())
    307             visitor->optimizeForStoppedMutator();
    308         m_availableParallelSlotVisitors.append(visitor.get());
    309         m_parallelSlotVisitors.append(WTFMove(visitor));
    310     }
    311303   
    312304    if (Options::useConcurrentGC()) {
    … …  
    12621254            {
    12631255                LockHolder locker(m_parallelSlotVisitorLock);
    1264                 RELEASE_ASSERT_WITH_MESSAGE(!m_availableParallelSlotVisitors.isEmpty(), "Parallel SlotVisitors are allocated apriori");
    1265                 slotVisitor = m_availableParallelSlotVisitors.takeLast();
     1256                if (m_availableParallelSlotVisitors.isEmpty()) {
     1257                    std::unique_ptr<SlotVisitor> newVisitor = std::make_unique<SlotVisitor>(
     1258                        *this, toCString("P", m_parallelSlotVisitors.size() + 1));
     1259                   
     1260                    if (Options::optimizeParallelSlotVisitorsForStoppedMutator())
     1261                        newVisitor->optimizeForStoppedMutator();
     1262                   
     1263                    newVisitor->didStartMarking();
     1264                   
     1265                    slotVisitor = newVisitor.get();
     1266                    m_parallelSlotVisitors.append(WTFMove(newVisitor));
     1267                } else
     1268                    slotVisitor = m_availableParallelSlotVisitors.takeLast();
    12661269            }
    12671270
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r241849 r242070  
    394394    template<typename Func>
    395395    void forEachSlotVisitor(const Func&);
     396    unsigned numberOfSlotVisitors();
    396397   
    397398    Seconds totalGCTime() const { return m_totalGCTime; }
  • trunk/Source/JavaScriptCore/heap/HeapInlines.h

    r241927 r242070  
    276276void Heap::forEachSlotVisitor(const Func& func)
    277277{
     278    auto locker = holdLock(m_parallelSlotVisitorLock);
    278279    func(*m_collectorSlotVisitor);
    279280    func(*m_mutatorSlotVisitor);
    … …  
    282283}
    283284
     285inline unsigned Heap::numberOfSlotVisitors()
     286{
     287    auto locker = holdLock(m_parallelSlotVisitorLock);
     288    return m_parallelSlotVisitors.size() + 2; // m_collectorSlotVisitor and m_mutatorSlotVisitor
     289}
     290
    284291} // namespace JSC
  • trunk/Source/JavaScriptCore/heap/MarkingConstraintSolver.cpp

    r239427 r242070  
    5252            return true;
    5353    }
     54    // If the number of SlotVisitors increases after creating m_visitCounters,
     55    // we conservatively say there could be something visited by added SlotVisitors.
     56    if (m_heap.numberOfSlotVisitors() > m_visitCounters.size())
     57        return true;
    5458    return false;
    5559}
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.h

    r240449 r242070  
    260260    MarkingConstraintSolver* m_currentSolver { nullptr };
    261261   
    262     // Put padding here to mitigate false sharing between multiple SlotVisitors.
    263     char padding[64];
    264262public:
    265263#if !ASSERT_DISABLED
Note: See TracChangeset for help on using the changeset viewer.