[all-commits] [llvm/llvm-project] bdf3e7: [trace][intelpt] Add task timer classes

walter erquinigo via All-commits all-commits at lists.llvm.org
Tue Apr 12 13:08:22 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bdf3e7e5b886ab690a82e8d34b4502d9c6c5d6a9
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2022-04-12 (Tue, 12 Apr 2022)

  Changed paths:
    M lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
    M lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
    A lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
    A lldb/source/Plugins/Trace/intel-pt/TaskTimer.h
    M lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    M lldb/test/API/commands/trace/TestTraceDumpInfo.py
    M lldb/test/API/commands/trace/TestTraceLoad.py

  Log Message:
  [trace][intelpt] Add task timer classes

I'm adding two new classes that can be used to measure the duration of long
tasks as process and thread level, e.g. decoding, fetching data from
lldb-server, etc. In this first patch, I'm using it to measure the time it takes
to decode each thread, which is printed out with the `dump info` command. In a
later patch I'll start adding process-level tasks and I might move these
classes to the upper Trace level, instead of having them in the intel-pt
plugin. I might need to do that anyway in the future when we have to
measure HTR. For now, I want to keep the impact of this change minimal.

With it, I was able to generate the following info of a very big trace:

(lldb) thread trace dump info                                                                                                            Trace technology: intel-pt

thread #1: tid = 616081
  Total number of instructions: 9729366

  Memory usage:
    Raw trace size: 1024 KiB
    Total approximate memory usage (excluding raw trace): 123517.34 KiB
    Average memory usage per instruction (excluding raw trace): 13.00 bytes

    Decoding instructions: 1.62s

    Number of TSC decoding errors: 0

As seen above, it took 1.62 seconds to decode 9.7M instructions. This is great
news, as we don't need to do any optimization work in this area.

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

  Commit: 44103c96fa6b00e7824319de1b10ce26781e3852
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2022-04-12 (Tue, 12 Apr 2022)

  Changed paths:
    M lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
    M lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
    M lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h

  Log Message:
  [trace][intelpt] Remove code smell when printing the raw trace size

Something ugly I did was to report the trace buffer size to the DecodedThread,
which is later used as part of the `dump info` command. Instead of doing that,
we can just directly ask the trace for the raw buffer and print its size.

I thought about not asking for the entire trace but instead just for its size,
but in this case, as our traces as not extremely big, I prefer to ask for the
entire trace, ensuring it could be fetched, and then print its size.

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

Compare: https://github.com/llvm/llvm-project/compare/9f526057d649...44103c96fa6b

More information about the All-commits mailing list