summaryrefslogtreecommitdiff
path: root/tools/llvm-xray
AgeCommit message (Collapse)Author
2017-12-13Remove redundant includes from tools.Michael Zolotukhin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21xray-record-yaml.h: Remove unused fileDavid Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318715 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-07[XRay] Minimal tool to convert xray traces to Chrome's Trace Event Format.Keith Wyss
Minimal tool to convert xray traces to Chrome's Trace Event Format. Summary: Make use of Chrome Trace Event format's Duration events and stack frame dict to produce Json files that chrome://tracing can visualize from xray function call traces. Trace Event format is more robust and has several features like argument logging, function categorization, multi process traces, etc. that we can add as needed. Duration events cover an important base case. Part of this change is rearranging the code so that the TrieNode data structure can be used from multiple tools and can carry parameterized baggage on the nodes. I put the actual behavior changes in llvm-xray convert exclusively. Exploring the trace of instrumented llc was pretty nifty if overwhelming. I can envision this being very useful for analyzing contention scenarios or tuning parameters like batch sizes in a producer consumer queue. For more targeted traces likemthis, let's talk about how we want to approach trace pruning. Reviewers: dberris, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39362 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317531 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-13Removing default case statement from covered switch.Keith Wyss
Previous patch did not count on the llvm command line parser to restrict the inputs, but it is safe to do so. Fix forward for patch with details: -- https://reviews.llvm.org/D38650 and -- https://llvm.org/svn/llvm-project/llvm/trunk@315635 91177308-0d34-0410-b5e6-96231b3b80d8 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315644 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-12[XRay][tools] Updated stacks tool with flamegraph output.Keith Wyss
Summary: As the first step to allow analysis and visualization of xray collected data, allow using the llvm-xray stacks tool to emit a complete listing of stacks in the format consumable by a flamegraph tool. Possible follow up formats include chrome trace viewer format and sql load files. As a POC, I'm able to generate flamegraphs of an xray instrumented llc compiling hello world. Reviewers: dberris, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38650 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315635 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27[XRay] fix the -Werror build by handling all enum cases in switchesMartin Pelikan
Followup to D32840. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314270 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27[XRay] convert FDR arg1 log entriesMartin Pelikan
Summary: A new FDR metadata record will support logging a function call argument; appending multiple metadata records will represent a sequence of arguments meaning that "holes" are not representable by the buffer format. Each call argument is currently a 64-bit value (useful for "this" pointers and synchronization objects). If present, we put this argument to the function call "entry" record it belongs to, and alter its type to notify the user of its presence. Reviewers: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32840 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314269 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18[XRay][tools] Support tail-call exits before we write them in the runtimeDean Michael Berris
Summary: This change adds support for explicit tail-exit records to be written by the XRay runtime. This lets us differentiate the tail exit records/events in the log, and allows us to treat those exit events especially in the future. For now we allow printing those out in YAML (and reading them in). Reviewers: kpw, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37964 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07Don't call exit from cl::PrintHelpMessage.Rafael Espindola
Most callers were not expecting the exit(0) and trying to exit with a different value. This also adds back the call to cl::PrintHelpMessage in llvm-ar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312761 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07[XRay][tools] Function call stack based analysis tooling for XRay tracesKeith Wyss
Second try after fixing a code san problem with iterator reference types. This change introduces a subcommand to the llvm-xray tool called "stacks" which allows for analysing XRay traces provided as inputs and accounting time to stacks instead of just individual functions. This gives us a more precise view of where in a program the latency is actually attributed. The tool uses a trie data structure to keep track of the caller-callee relationships as we process the XRay traces. In particular, we keep track of the function call stack as we enter functions. While we're doing this we're adding nodes in a trie and indicating a "calls" relatinship between the caller (current top of the stack) and the callee (the new top of the stack). When we push function ids onto the stack, we keep track of the timestamp (TSC) for the enter event. When exiting functions, we are able to account the duration by getting the difference between the timestamp of the exit event and the corresponding entry event in the stack. This works even if we somehow miss the exit events for intermediary functions (i.e. if the exit event is not cleanly associated with the enter event at the top of the stack). The output of the tool currently provides just the top N leaf functions that contribute the most latency, and the top N stacks that have the most frequency. In the future we can provide more sophisticated query mechanisms and potentially an export to database feature to make offline analysis of the stack traces possible with existing tools. Differential revision: D34863 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312733 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-03Revert "[XRay][tools] Function call stack based analysis tooling for XRay ↵Keith Wyss
traces" This reverts commit 204a65e0702847a1880336372ad7abd1df414b44. Double ref qualifier failed bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312428 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-03[XRay][tools] Function call stack based analysis tooling for XRay tracesKeith Wyss
This change introduces a subcommand to the llvm-xray tool called "stacks" which allows for analysing XRay traces provided as inputs and accounting time to stacks instead of just individual functions. This gives us a more precise view of where in a program the latency is actually attributed. The tool uses a trie data structure to keep track of the caller-callee relationships as we process the XRay traces. In particular, we keep track of the function call stack as we enter functions. While we're doing this we're adding nodes in a trie and indicating a "calls" relatinship between the caller (current top of the stack) and the callee (the new top of the stack). When we push function ids onto the stack, we keep track of the timestamp (TSC) for the enter event. When exiting functions, we are able to account the duration by getting the difference between the timestamp of the exit event and the corresponding entry event in the stack. This works even if we somehow miss the exit events for intermediary functions (i.e. if the exit event is not cleanly associated with the enter event at the top of the stack). The output of the tool currently provides just the top N leaf functions that contribute the most latency, and the top N stacks that have the most frequency. In the future we can provide more sophisticated query mechanisms and potentially an export to database feature to make offline analysis of the stack traces possible with existing tools. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31[XRay][tools] Fix an accounting bug in llvm-xray accountDean Michael Berris
Summary: Before this patch, llvm-xray account will assume that thread stacks will not be empty. Unfortunately there are cases where an instrumented function will see a call to `fork()` which will cause the child process to not see the start of the function, but only see the end of the function. The tooling cannot assume that threads will always have perfect stacks, and so we change it to support this reality. Reviewers: dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31870 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312204 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304864 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26[XRay][tools] Remove wayward semicolon (NFC)Dean Michael Berris
Follow-up to D29320. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301378 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26[XRay][tools] Fixup definition for stat division.Dean Michael Berris
Copy-pasta error. Follow-up to D29320. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301376 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[XRay][tools] Fixup for pedantic and permissive errors/warningsDean Michael Berris
Remove extraneous semicolons and fully qualify the Trace type. Follow-up to D29320. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301161 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24[XRay] A tool for Comparing xray function call graphsDean Michael Berris
Summary: This is a tool for comparing the function graphs produced by the llvm-xray graph too. It takes the form of a new subcommand of the llvm-xray tool 'graph-diff'. This initial version of the patch is very rough, but it is close to feature complete. Depends on D29363 Reviewers: dblaikie, dberris Reviewed By: dberris Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D29320 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301160 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18[XRay][tools] Add option to llvm-xray extract to symbolize functionsDean Michael Berris
Summary: This allows us to, if the symbol names are available in the binary, be able to provide the function name in the YAML output. Reviewers: dblaikie, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32153 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300624 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31[XRay][tools] Remove some assertions in llvm-xray graphDean Michael Berris
Summary: Assertions assuming that function calls may not have zero durations do not seem to hold in the wild. There are valid cases where the conversion of the tsc counters end up becoming zero-length durations. These assertions don't really hold and the algorithms don't need those to be true for them to work. Reviewers: dblaikie, echristo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31519 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299150 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-29[XRay][tools] Handle "no subcommand" case for llvm-xrayDean Michael Berris
Summary: Currently the llvm-xray commandline tool fails to handle the case for when no subcommand is provided in a graceful manner. This fixes that to print the help message explaining the subcommands and the available options. Reviewers: pcc, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31409 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298975 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-25[XRAY] A Color Choosing helper for XRay GraphDean Michael Berris
Summary: In Preparation for graph comparison, this patch breaks out the color choice code from xray-graph into a library and adds polynomials for the Sequential and Difference sets from ColorBrewer. Depends on D29005 Reviewers: dblaikie, chandlerc, dberris Reviewed By: dberris Subscribers: chandlerc, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D29363 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296210 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17[XRAY] [x86_64] Adding a Flight Data filetype reader to the llvm-xray Trace ↵Dean Michael Berris
implementation. Summary: The file type packs function trace data onto disk from potentially multiple threads that are aggregated and flushed during the course of an instrumented program's runtime. It is named FDR mode or Flight Data recorder as an analogy to plane blackboxes, which instrument a running system without access to IO. The writer code is defined in compiler-rt in xray_fdr_logging.h/cc Reviewers: rSerge, kcc, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29697 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295397 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14Disable wrapping llvm-xray YAML outputDimitry Andric
Summary: The YAML output produced by llvm-xray is supposed to be wrapped at the arbitrary default of 70 columns set by `yaml:Output`. Unfortunately, the wrapping is rather unpredictable, and can easily go past the set number of columns, depending on the execution environment. To make the YAML output environment-independent, disable wrapping instead. Reviewers: dberris Reviewed By: dberris Subscribers: fhahn, llvm-commits Differential Revision: https://reviews.llvm.org/D29962 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295116 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10[XRay] A graph Class for the llvm-xray graphDean Michael Berris
Summary: In preparation for graph comparison and filtering, this is a library for representing graphs in LLVM. This will enable easier encapsulation and reuse of graphs in llvm-xray. Depends on D28999, D28225 Reviewers: dblaikie, dberris Reviewed By: dberris Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D29005 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294717 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10Revert "[XRay] A graph Class for the llvm-xray graph"Dean Michael Berris
Broke tests, reverting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294714 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10[XRay] A graph Class for the llvm-xray graphDean Michael Berris
Summary: In preparation for graph comparison and filtering, this is a library for representing graphs in LLVM. This will enable easier encapsulation and reuse of graphs in llvm-xray. Depends on D28999, D28225 Reviewers: dblaikie, dberris Reviewed By: dberris Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D29005 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294713 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-01[XRay] Use std::errc::invalid_argument instead of std::errc::bad_messageDean Michael Berris
This change should appease the mingw32 builds. Follow-up to D29319. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293725 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-01[XRay] Define the InstrumentationMap typeDean Michael Berris
Summary: This change implements the instrumentation map loading library which can understand both YAML-defined instrumentation maps, and ELF 64-bit object files that have the XRay instrumentation map section. We break it out into a library on its own to allow for other applications to deal with the XRay instrumentation map defined in XRay-instrumented binaries. This type provides both raw access to the logical representation of the instrumentation map entries as well as higher level functions for converting a function ID into a function address. At this point we only support ELF64 binaries and YAML-defined XRay instrumentation maps. Future changes should extend this to support 32-bit ELF binaries, as well as other binary formats (like MachO). As part of this change we also migrate all uses of the extraction logic that used to be defined in tools/llvm-xray/ to use this new type and interface for loading from files. We also remove the flag from the `llvm-xray` tool that required users to specify the type of the instrumentation map file being provided to instead make the library auto-detect the file type. Reviewers: dblaikie Subscribers: mgorny, varno, llvm-commits Differential Revision: https://reviews.llvm.org/D29319 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293721 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-28Remove unused 'using' declaration. Found by clang-tidy: ↵Sylvestre Ledru
misc-unused-using-decls NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293382 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25Implemented color coding and Vertex labels in XRay GraphDean Michael Berris
Summary: A patch to enable the llvm-xray graph subcommand to color edges and vertices based on statistics and to annotate vertices with statistics. Depends on D27243 Reviewers: dblaikie, dberris Reviewed By: dberris Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D28225 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293031 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17Remove pid_t usage from llvm-xrayPavel Labath
This type is not available on windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292206 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16Add missing header to see if that clears up the buildDavid Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292166 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16Attempt to fix the MSVC build by using llvm::errc instead of std::errcDavid Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292163 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16[XRay] Implement the `llvm-xray graph` subcommandDavid Blaikie
Here we define the `graph` subcommand which generates a graph from the function call information and uses it to present the call information graphically with additional annotations. Reviewers: dblaikie, dberris Differential Revision: https://reviews.llvm.org/D27243 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292156 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16[llvm-xray] Fix android buildPavel Labath
std::to_string is not available in the android ndk. Using llvm::to_string instead. Committing as obvious. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292143 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13xray-account: Avoid std::errc::bad_message to appease mingw.NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291863 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12Avoid std::errc::protocol_* to appease mingwHans Wennborg
Like r291636 and r285261. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291786 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12Fix windows buildbots building llvm-xraySimon Pilgrim
2 issues: 1 - replaced unix-style pid_t with cross-platform llvm::sys::ProcessInfo::ProcessId 2 - fixed shadow variable warning in lambda expression Reviewed by @filcab git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291760 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12[XRay] Include <numeric> for std::accumulate.Dean Michael Berris
Fix-up following D24377. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291750 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12[XRay] Implement the `llvm-xray account` subcommandDean Michael Berris
Summary: This is the third of a multi-part change to implement subcommands for the `llvm-xray` tool. Here we define the `account` subcommand which does simple function call accounting, generating basic statistics on function calls we find in an XRay log/trace. We support text output and csv output for this subcommand. This change also supports sorting, summing, and filtering the top N results. Part of this tool will later be turned into a library that could be used for basic function call accounting. Depends on D24376. Reviewers: dblaikie, echristo Subscribers: mehdi_amini, dberris, beanz, llvm-commits Differential Revision: https://reviews.llvm.org/D24377 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291749 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-11[XRay] Define the library for XRay trace logsDean Michael Berris
Summary: In this change we move the definition of the log reading routines from the tools directory in LLVM to {include/llvm,lib}/XRay. We improve the documentation a little bit for the publicly accessible headers, and adjust the top-matter. This also leads to some refactoring and cleanup in the tooling code. In particular, we do the following: - Rename the class from LogReader to Trace, as it better represents the logical set of records as opposed to a log. - Use file type detection instead of asking the user to say what format the input file is. This allows us to keep the interface simple and encapsulate the logic of loading the data appropriately. In future changes we increase the API surface and write dedicated unit tests for the XRay library. Depends on D24376. Reviewers: dblaikie, echristo Subscribers: mehdi_amini, mgorny, llvm-commits, varno Differential Revision: https://reviews.llvm.org/D28345 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291652 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-11tools/llvm-xray: Avoid std::errc::protocol_* to appease mingw, like r285261.NAKAMURA Takumi
They are oriented from winsock and mingw doesn't import them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291636 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-10[XRay] Fixup includes for modules buildDean Michael Berris
Remove unnecessary system header include. Follow-up to D24376. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291533 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-10[XRay] Don't include <unistd.h> unnecessarilyDean Michael Berris
Follow-up to D24376. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291531 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-10[XRay] Implement `llvm-xray convert` -- trace file conversionDean Michael Berris
This is the second part of a multi-part change to define additional subcommands to the `llvm-xray` tool. This change defines a conversion subcommand to take XRay log files, and turns them from one format to another (binary or YAML). This currently only supports the first version of the log file format, defined in the compiler-rt runtime. Depends on D21987. Reviewers: dblaikie, echristo Subscribers: mehdi_amini, dberris, beanz, llvm-commits Differential Revision: https://reviews.llvm.org/D24376 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291529 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11Make the Error class constructor protectedMehdi Amini
This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286561 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27xray-extract.cc: Quick fix for mingw, to avoid errc::protocol_error.NAKAMURA Takumi
errc::protocol_error is winsock-oriented and mingw doesn't include it. (MS does, though) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285261 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26[XRay] Remove unnecessary include of <unistd.h>Dean Michael Berris
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285171 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26[XRay] Remove unnecessary include of <unistd.h>Dean Michael Berris
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285170 91177308-0d34-0410-b5e6-96231b3b80d8