Ignore:
Timestamp:
Nov 29, 2017, 8:48:52 PM (8 years ago)
Author:
[email protected]
Message:

CodeBlockSet::deleteUnmarkedAndUnreferenced can be a little more efficient
https://bugs.webkit.org/show_bug.cgi?id=180108

Reviewed by Saam Barati.

This was creating a vector of things to remove and then removing them. I think I remember writing
this code, and I did that because at the time we did not have removeAllMatching, which is
definitely better. This is a minuscule optimization for Speedometer. I wanted to land this
obvious improvement before I did more fundamental things to this code.

  • heap/CodeBlockSet.cpp:

(JSC::CodeBlockSet::deleteUnmarkedAndUnreferenced):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/CodeBlockSet.cpp

    r219702 r225315  
    2929#include "CodeBlock.h"
    3030#include "JSCInlines.h"
     31#include "SuperSampler.h"
    3132#include <wtf/CommaPrinter.h>
    3233
     
    7576{
    7677    LockHolder locker(&m_lock);
    77     Vector<CodeBlock*> unmarked;
     78   
     79    // Destroying a CodeBlock takes about 1us on average in Speedometer. Full collections in Speedometer
     80    // usually have ~2000 CodeBlocks to process. The time it takes to process the whole list varies a
     81    // lot. In one extreme case I saw 18ms (on my fast MBP).
     82    //
     83    // FIXME: use Subspace instead of HashSet and adopt Subspace-based constraint solving. This may
     84    // remove the need to eagerly destruct CodeBlocks.
     85    // https://bugs.webkit.org/show_bug.cgi?id=180089
     86    //
     87    // FIXME: make CodeBlock::~CodeBlock a lot faster. It seems insane for that to take 1us or more.
     88    // https://bugs.webkit.org/show_bug.cgi?id=180109
    7889   
    7990    auto consider = [&] (HashSet<CodeBlock*>& set) {
    80         for (CodeBlock* codeBlock : set) {
    81             if (Heap::isMarked(codeBlock))
    82                 continue;;
    83             unmarked.append(codeBlock);
    84         }
    85         for (CodeBlock* codeBlock : unmarked) {
    86             codeBlock->structure(vm)->classInfo()->methodTable.destroy(codeBlock);
    87             set.remove(codeBlock);
    88         }
    89         unmarked.shrink(0);
     91        set.removeIf(
     92            [&] (CodeBlock* codeBlock) -> bool {
     93                if (Heap::isMarked(codeBlock))
     94                    return false;
     95                codeBlock->structure(vm)->classInfo()->methodTable.destroy(codeBlock);
     96                return true;
     97            });
    9098    };
    9199
Note: See TracChangeset for help on using the changeset viewer.