mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
6542491095
Summary: Instruments is a useful tool for finding performance issues in LLVM but it can be difficult to identify regions of interest on the timeline that we can use to filter the profiler or allocations instrument. Xcode 10 and the latest macOS/iOS/etc. added support for the os_signpost() API which allows us to annotate the timeline with information that's meaningful to LLVM. This patch causes timer start and end events to emit signposts. When used with -time-passes, this causes the passes to be annotated on the Instruments timeline. In addition to visually showing the duration of passes on the timeline, it also allows us to filter the profile and allocations instrument down to an individual pass allowing us to find the issues within that pass without being drowned out by the noise from other parts of the compiler. Using this in conjunction with the Time Profiler (in high frequency mode) and the Allocations instrument is how I found the SparseBitVector that should have been a BitVector and the DenseMap that could be replaced by a sorted vector a couple months ago. I added NamedRegionTimers to TableGen and used the resulting annotations to identify the slow portions of the Register Info Emitter. Some of these were placed according to educated guesses while others were placed according to hot functions from a previous profile. From there I filtered the profile to a slow portion and the aforementioned issues stood out in the profile. To use this feature enable LLVM_SUPPORT_XCODE_SIGNPOSTS in CMake and run the compiler under Instruments with -time-passes like so: instruments -t 'Time Profiler' bin/llc -time-passes -o - input.ll' Then open the resulting trace in Instruments. There was a talk at WWDC 2018 that explained the feature which can be found at https://developer.apple.com/videos/play/wwdc2018/405/ if you'd like to know more about it. Reviewers: bogner Reviewed By: bogner Subscribers: jdoerfert, mgorny, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D52954 llvm-svn: 354365
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
//===-- llvm/Support/Signposts.h - Interval debug annotations ---*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file Some OS's provide profilers that allow applications to provide custom
|
|
/// annotations to the profiler. For example, on Xcode 10 and later 'signposts'
|
|
/// can be emitted by the application and these will be rendered to the Points
|
|
/// of Interest track on the instruments timeline.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_SUPPORT_SIGNPOSTS_H
|
|
#define LLVM_SUPPORT_SIGNPOSTS_H
|
|
|
|
namespace llvm {
|
|
class SignpostEmitterImpl;
|
|
class Timer;
|
|
|
|
/// Manages the emission of signposts into the recording method supported by
|
|
/// the OS.
|
|
class SignpostEmitter {
|
|
SignpostEmitterImpl *Impl;
|
|
|
|
public:
|
|
SignpostEmitter();
|
|
~SignpostEmitter();
|
|
|
|
bool isEnabled() const;
|
|
|
|
/// Begin a signposted interval for the given timer.
|
|
void startTimerInterval(Timer *T);
|
|
/// End a signposted interval for the given timer.
|
|
void endTimerInterval(Timer *T);
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // ifndef LLVM_SUPPORT_SIGNPOSTS_H
|