Title: [276175] branches/safari-611-branch/Source/_javascript_Core
Revision
276175
Author
[email protected]
Date
2021-04-16 15:28:44 -0700 (Fri, 16 Apr 2021)

Log Message

Cherry-pick r276155. rdar://problem/76781047

    Before deleting a MarkedBlock we do not need to clear its m_directory pointer.
    https://bugs.webkit.org/show_bug.cgi?id=224677

    Reviewed by Yusuke Suzuki.

    Right now when we are about to free a MarkedBlock we clear the
    m_directory pointer in the MarkedBlock's Handle. This has the
    downside, however, of potentially paging in the footer from disk /
    the compressor, which some data we have seen shows is happening.
    This patch prevents this uncessary store to hopefully reduce the
    number of pageins/decompressions caused by Safari web content.

    * heap/BlockDirectory.cpp:
    (JSC::BlockDirectory::removeBlock):
    (JSC::BlockDirectory::removeBlockForDeletion):
    * heap/BlockDirectory.h:
    * heap/MarkedBlock.cpp:
    (JSC::MarkedBlock::Handle::~Handle):
    * heap/MarkedSpace.cpp:
    (JSC::MarkedSpace::freeBlock):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276155 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/_javascript_Core/ChangeLog (276174 => 276175)


--- branches/safari-611-branch/Source/_javascript_Core/ChangeLog	2021-04-16 22:16:21 UTC (rev 276174)
+++ branches/safari-611-branch/Source/_javascript_Core/ChangeLog	2021-04-16 22:28:44 UTC (rev 276175)
@@ -1,3 +1,54 @@
+2021-04-16  Alan Coon  <[email protected]>
+
+        Cherry-pick r276155. rdar://problem/76781047
+
+    Before deleting a MarkedBlock we do not need to clear its m_directory pointer.
+    https://bugs.webkit.org/show_bug.cgi?id=224677
+    
+    Reviewed by Yusuke Suzuki.
+    
+    Right now when we are about to free a MarkedBlock we clear the
+    m_directory pointer in the MarkedBlock's Handle. This has the
+    downside, however, of potentially paging in the footer from disk /
+    the compressor, which some data we have seen shows is happening.
+    This patch prevents this uncessary store to hopefully reduce the
+    number of pageins/decompressions caused by Safari web content.
+    
+    * heap/BlockDirectory.cpp:
+    (JSC::BlockDirectory::removeBlock):
+    (JSC::BlockDirectory::removeBlockForDeletion):
+    * heap/BlockDirectory.h:
+    * heap/MarkedBlock.cpp:
+    (JSC::MarkedBlock::Handle::~Handle):
+    * heap/MarkedSpace.cpp:
+    (JSC::MarkedSpace::freeBlock):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-04-16  Keith Miller  <[email protected]>
+
+            Before deleting a MarkedBlock we do not need to clear its m_directory pointer.
+            https://bugs.webkit.org/show_bug.cgi?id=224677
+
+            Reviewed by Yusuke Suzuki.
+
+            Right now when we are about to free a MarkedBlock we clear the
+            m_directory pointer in the MarkedBlock's Handle. This has the
+            downside, however, of potentially paging in the footer from disk /
+            the compressor, which some data we have seen shows is happening.
+            This patch prevents this uncessary store to hopefully reduce the
+            number of pageins/decompressions caused by Safari web content.
+
+            * heap/BlockDirectory.cpp:
+            (JSC::BlockDirectory::removeBlock):
+            (JSC::BlockDirectory::removeBlockForDeletion):
+            * heap/BlockDirectory.h:
+            * heap/MarkedBlock.cpp:
+            (JSC::MarkedBlock::Handle::~Handle):
+            * heap/MarkedSpace.cpp:
+            (JSC::MarkedSpace::freeBlock):
+
 2021-04-15  Russell Epstein  <[email protected]>
 
         Cherry-pick r275233. rdar://problem/76727522

Modified: branches/safari-611-branch/Source/_javascript_Core/heap/BlockDirectory.cpp (276174 => 276175)


--- branches/safari-611-branch/Source/_javascript_Core/heap/BlockDirectory.cpp	2021-04-16 22:16:21 UTC (rev 276174)
+++ branches/safari-611-branch/Source/_javascript_Core/heap/BlockDirectory.cpp	2021-04-16 22:28:44 UTC (rev 276175)
@@ -140,7 +140,7 @@
     setIsEmpty(NoLockingNecessary, index, true);
 }
 
-void BlockDirectory::removeBlock(MarkedBlock::Handle* block)
+void BlockDirectory::removeBlock(MarkedBlock::Handle* block, WillDeleteBlock willDelete)
 {
     ASSERT(block->directory() == this);
     ASSERT(m_blocks[block->index()] == block);
@@ -155,8 +155,9 @@
         [&](auto vectorRef) {
             vectorRef[block->index()] = false;
         });
-    
-    block->didRemoveFromDirectory();
+
+    if (willDelete == WillDeleteBlock::No)
+        block->didRemoveFromDirectory();
 }
 
 void BlockDirectory::stopAllocating()

Modified: branches/safari-611-branch/Source/_javascript_Core/heap/BlockDirectory.h (276174 => 276175)


--- branches/safari-611-branch/Source/_javascript_Core/heap/BlockDirectory.h	2021-04-16 22:16:21 UTC (rev 276174)
+++ branches/safari-611-branch/Source/_javascript_Core/heap/BlockDirectory.h	2021-04-16 22:28:44 UTC (rev 276175)
@@ -83,7 +83,9 @@
     RefPtr<SharedTask<MarkedBlock::Handle*()>> parallelNotEmptyBlockSource();
     
     void addBlock(MarkedBlock::Handle*);
-    void removeBlock(MarkedBlock::Handle*);
+    enum class WillDeleteBlock { No, Yes };
+    // If WillDeleteBlock::Yes is passed then the block will be left in an invalid state. We do this, however, to avoid potentially paging in / decompressing old blocks to update their handle just before freeing them.
+    void removeBlock(MarkedBlock::Handle*, WillDeleteBlock = WillDeleteBlock::No);
 
     bool isPagedOut(MonotonicTime deadline);
     

Modified: branches/safari-611-branch/Source/_javascript_Core/heap/MarkedBlock.cpp (276174 => 276175)


--- branches/safari-611-branch/Source/_javascript_Core/heap/MarkedBlock.cpp	2021-04-16 22:16:21 UTC (rev 276174)
+++ branches/safari-611-branch/Source/_javascript_Core/heap/MarkedBlock.cpp	2021-04-16 22:28:44 UTC (rev 276175)
@@ -76,7 +76,7 @@
         if (!(balance % 10))
             dataLog("MarkedBlock Balance: ", balance, "\n");
     }
-    removeFromDirectory();
+    m_directory->removeBlock(this, BlockDirectory::WillDeleteBlock::Yes);
     m_block->~MarkedBlock();
     m_alignedMemoryAllocator->freeAlignedMemory(m_block);
     heap.didFreeBlock(blockSize);

Modified: branches/safari-611-branch/Source/_javascript_Core/heap/MarkedSpace.cpp (276174 => 276175)


--- branches/safari-611-branch/Source/_javascript_Core/heap/MarkedSpace.cpp	2021-04-16 22:16:21 UTC (rev 276174)
+++ branches/safari-611-branch/Source/_javascript_Core/heap/MarkedSpace.cpp	2021-04-16 22:28:44 UTC (rev 276175)
@@ -371,7 +371,6 @@
 
 void MarkedSpace::freeBlock(MarkedBlock::Handle* block)
 {
-    block->directory()->removeBlock(block);
     m_capacity -= MarkedBlock::blockSize;
     m_blocks.remove(&block->block());
     delete block;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to