[all-commits] [llvm/llvm-project] 4a843d: [trace][intel pt] Create a CPU change event and ex...

walter erquinigo via All-commits all-commits at lists.llvm.org
Wed Jul 13 12:26:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a843d9282754b1c96c8d9fcbbbe45f000b42452
      https://github.com/llvm/llvm-project/commit/4a843d9282754b1c96c8d9fcbbbe45f000b42452
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2022-07-13 (Wed, 13 Jul 2022)

  Changed paths:
    M lldb/include/lldb/Target/TraceCursor.h
    M lldb/include/lldb/Target/TraceDumper.h
    M lldb/include/lldb/lldb-enumerations.h
    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/TraceCursorIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
    M lldb/source/Target/TraceCursor.cpp
    M lldb/source/Target/TraceDumper.cpp
    M lldb/test/API/commands/trace/TestTraceEvents.py
    M lldb/test/API/commands/trace/TestTraceLoad.py

  Log Message:
  -----------
  [trace][intel pt] Create a CPU change event and expose it in the dumper

Thanks to fredzhou at fb.com for coming up with this feature.

When tracing in per-cpu mode, we have information of in which cpu we are execution each instruction, which comes from the context switch trace. This diff makes this information available as a `cpu changed event`, which an additional accessor in the cursor `GetCPU()`. As cpu changes are very infrequent, any consumer should listen to cpu change events instead of querying the actual cpu of a trace item. Once a cpu change event is seen, the consumer can invoke GetCPU() to get that information. Also, it's possible to invoke GetCPU() on an arbitrary instruction item, which will return the last cpu seen. However, this call is O(logn) and should be used sparingly.

Manually tested with a sample program that starts on cpu 52, then goes to 18, and then goes back to 52.

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


  Commit: d30fd5c3a17b5b8301e3413ae9b398ca7ee1f69c
      https://github.com/llvm/llvm-project/commit/d30fd5c3a17b5b8301e3413ae9b398ca7ee1f69c
  Author: Gaurav Gaur <gaur at fb.com>
  Date:   2022-07-13 (Wed, 13 Jul 2022)

  Changed paths:
    M lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h
    M lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
    M lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
    M lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h
    M lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
    M lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h
    M lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td
    M lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp

  Log Message:
  -----------
  [trace][intel pt] Add a cgroup filter

It turns out that cgroup filtering is relatively trivial and works
really nicely. Thid diffs adds automatic cgroup filtering when in
per-cpu mode, unless a new --disable-cgroup-filtering flag is passed in
the start command. At least on Meta machines, all processes are spawned
inside a cgroup by default, which comes super handy, because per cpu
tracing is now much more precise.

A manual test gave me this result

- Without filtering:
    Total number of trace items: 36083
    Total number of continuous executions found: 229
    Number of continuous executions for this thread: 2
    Total number of PSB blocks found: 98
    Number of PSB blocks for this thread 2
    Total number of unattributed PSB blocks found: 38

- With filtering:
    Total number of trace items: 87756
    Total number of continuous executions found: 123
    Number of continuous executions for this thread: 2
    Total number of PSB blocks found: 10
    Number of PSB blocks for this thread 3
    Total number of unattributed PSB blocks found: 2

Filtering gives us great results. The number of instructions collected
more than double (probalby because we have less noise in the trace), and
we have much less unattributed PSBs blocks and unrelated PSBs in
general. The ones that are unrelated probably belong to other processes
in the same cgroup.

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


  Commit: 0466d1df23b9157144c32e03f6477ed250991215
      https://github.com/llvm/llvm-project/commit/0466d1df23b9157144c32e03f6477ed250991215
  Author: ymeng <ymeng at devvm4974.frc0.facebook.com>
  Date:   2022-07-13 (Wed, 13 Jul 2022)

  Changed paths:
    M lldb/include/lldb/Target/Trace.h
    M lldb/source/Commands/CommandObjectThread.cpp
    M lldb/source/Commands/Options.td
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp
    M lldb/source/Target/TraceDumper.cpp
    M lldb/test/API/commands/trace/TestTraceDumpInfo.py
    M lldb/test/API/commands/trace/TestTraceLoad.py

  Log Message:
  -----------
  [trace][intel pt] Support dumping the trace info in json

Thanks to ymeng at fb.com for coming up with this change.

`thread trace dump info` can dump some metrics that can be useful for
analyzing the performance and quality of a trace. This diff adds a --json
option for dumping this information in json format that can be easily
understood my machines.

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


Compare: https://github.com/llvm/llvm-project/compare/f7d42d5149dd...0466d1df23b9


More information about the All-commits mailing list