Commit 418893d8 authored by Adrian Prantl's avatar Adrian Prantl
Browse files

Speed up accelerator table lookups

When debugging a large program like clang and doing "frame variable
*this", the ValueObject pretty printer is doing hundreds of scoped
FindTypes lookups. The ones that take longest are the ones where the
DWARFDeclContext ends in something like ::Iterator which produces many
false positives that need to be filtered out *after* extracting the
DIEs. This patch demonstrates a way to filter out false positives at
the accerator table lookup step.

With this patch
  lldb clang-10 -o "b EmitFunctionStart" -o r -o "f 2" -o "fr v *this" -b -- ...
goes (in user time) from 5.6s -> 4.8s
or (in wall clock) from 6.9s -> 6.0s.

Differential Revision: https://reviews.llvm.org/D68678

llvm-svn: 374401
parent 715bfa4e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
# There is no guaranteed order in which the linker will order these
# files, so we just have a lot of them to make it unlikely that we hit
# the right one first by pure luck.

CXX_SOURCES := main.cpp a.cpp b.cpp c.cpp d.cpp e.cpp f.cpp g.cpp

include Makefile.rules
+31 −0
Original line number Diff line number Diff line
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class CPPAcceleratorTableTestCase(TestBase):

    mydir = TestBase.compute_mydir(__file__)

    @skipUnlessDarwin
    @skipIf(debug_info=no_match(["dwarf"]))
    def test(self):
        """Test that type lookups fail early (performance)"""
        self.build()
        logfile = self.getBuildArtifact('dwarf.log')
        self.expect('log enable dwarf lookups -f' + logfile)
        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
            self, 'break here', lldb.SBFileSpec('main.cpp'))
        # Pick one from the middle of the list to have a high chance
        # of it not being in the first file looked at.
        self.expect('frame variable inner_d')

        log = open(logfile, 'r')
        n = 0
        for line in log:
            if re.findall(r'[abcdefg]\.o: FindByNameAndTag\(\)', line):
                self.assertTrue("d.o" in line)
                n += 1

        self.assertEqual(n, 1, log)
+2 −0
Original line number Diff line number Diff line
#include "source.h"
CLASS(A)
+2 −0
Original line number Diff line number Diff line
#include "source.h"
CLASS(B)
+2 −0
Original line number Diff line number Diff line
#include "source.h"
CLASS(C)
Loading