forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XRay] Implement the
llvm-xray account
subcommand
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
- Loading branch information
1 parent
3517370
commit c4416a6
Showing
9 changed files
with
860 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This is a simple instrumentation map with bogus addresses and offsets, but | ||
# follow the recommended format. | ||
--- | ||
- { id: 1, address: 0x1, function: 0x1, kind: function-enter, always-instrument: true} | ||
- { id: 1, address: 0x2, function: 0x1, kind: function-exit, always-instrument: true} | ||
- { id: 2, address: 0x2, function: 0x2, kind: function-enter, always-instrument: true} | ||
- { id: 2, address: 0x3, function: 0x2, kind: function-exit, always-instrument: true} | ||
- { id: 3, address: 0x3, function: 0x3, kind: function-enter, always-instrument: true} | ||
- { id: 3, address: 0x4, function: 0x3, kind: function-exit, always-instrument: true} | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -d | FileCheck %s | ||
--- | ||
header: | ||
version: 1 | ||
type: 0 | ||
constant-tsc: true | ||
nonstop-tsc: true | ||
cycle-frequency: 0 | ||
records: | ||
# Here we reconstruct the following call trace: | ||
# | ||
# f1() | ||
# f2() | ||
# f3() | ||
# | ||
# But we find that we're missing an exit record for f2() because it's | ||
# tail-called f3(). We make sure that if we see a trace like this that we can | ||
# deduce tail calls, and account the time (potentially wrongly) to f2() when | ||
# f1() exits. That is because we don't go back to f3()'s entry record to | ||
# properly do the math on the timing of f2(). | ||
# | ||
# Note that by default, tail/sibling call deduction is disabled, and is enabled | ||
# with a flag "-d" or "-deduce-sibling-calls". | ||
# | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10000 } | ||
- { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-enter, tsc: 10001 } | ||
- { type: 0, func-id: 3, cpu: 1, thread: 111, kind: function-enter, tsc: 10002 } | ||
- { type: 0, func-id: 3, cpu: 1, thread: 111, kind: function-exit, tsc: 10003 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10004 } | ||
... | ||
|
||
#CHECK: Functions with latencies: 3 | ||
#CHECK-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#CHECK-NEXT: 1 1 [ 4.{{.*}}, 4.{{.*}}, 4.{{.*}}, 4.{{.*}}, 4.{{.*}}] {{.*}} {{.*}} | ||
#CHECK-NEXT: 2 1 [ 3.{{.*}}, 3.{{.*}}, 3.{{.*}}, 3.{{.*}}, 3.{{.*}}] {{.*}} {{.*}} | ||
#CHECK-NEXT: 3 1 [ 1.{{.*}}, 1.{{.*}}, 1.{{.*}}, 1.{{.*}}, 1.{{.*}}] {{.*}} {{.*}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -k | FileCheck %s | ||
--- | ||
header: | ||
version: 1 | ||
type: 0 | ||
constant-tsc: true | ||
nonstop-tsc: true | ||
cycle-frequency: 0 | ||
records: | ||
# We want to test the case for when we see spurious exits, but keep going | ||
# anyway ignoring the records in the process. | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10000 } | ||
- { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-enter, tsc: 10001 } | ||
- { type: 0, func-id: 3, cpu: 1, thread: 111, kind: function-enter, tsc: 10002 } | ||
- { type: 0, func-id: 3, cpu: 1, thread: 111, kind: function-exit, tsc: 10003 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10004 } | ||
... | ||
#CHECK: Functions with latencies: 1 | ||
#CHECK-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#CHECK-NEXT: 3 1 [ 1.{{.*}}, 1.{{.*}}, 1.{{.*}}, 1.{{.*}}, 1.{{.*}}] {{.*}} {{.*}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml | FileCheck %s | ||
--- | ||
header: | ||
version: 1 | ||
type: 0 | ||
constant-tsc: true | ||
nonstop-tsc: true | ||
cycle-frequency: 2601000000 | ||
records: | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, | ||
tsc: 10001 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, | ||
tsc: 10100 } | ||
... | ||
|
||
#CHECK: Functions with latencies: 1 | ||
#CHECK-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#CHECK-NEXT: 1 1 [ {{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml | FileCheck --check-prefix DEFAULT %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s count | FileCheck --check-prefix COUNT-ASC %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s min | FileCheck --check-prefix MIN-ASC %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s max | FileCheck --check-prefix MAX-ASC %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s sum | FileCheck --check-prefix SUM-ASC %s | ||
|
||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s count -r dsc | FileCheck --check-prefix COUNT-DSC %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s min -r dsc | FileCheck --check-prefix MIN-DSC %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s max -r dsc | FileCheck --check-prefix MAX-DSC %s | ||
#RUN: llvm-xray account %s -o - -m %S/Inputs/simple-instrmap.yaml -t yaml -s sum -r dsc | FileCheck --check-prefix SUM-DSC %s | ||
--- | ||
header: | ||
version: 1 | ||
type: 0 | ||
constant-tsc: true | ||
nonstop-tsc: true | ||
cycle-frequency: 1 | ||
records: | ||
# Function id: 1 | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, | ||
tsc: 10001 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, | ||
tsc: 10100 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, | ||
tsc: 10101 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, | ||
tsc: 10200 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, | ||
tsc: 10201 } | ||
- { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-exit, | ||
tsc: 10300 } | ||
# Function id: 2 | ||
- { type: 0, func-id: 2, cpu: 1, thread: 222, kind: function-enter, | ||
tsc: 10001 } | ||
- { type: 0, func-id: 2, cpu: 1, thread: 222, kind: function-exit, | ||
tsc: 10002 } | ||
- { type: 0, func-id: 2, cpu: 1, thread: 222, kind: function-enter, | ||
tsc: 10101 } | ||
- { type: 0, func-id: 2, cpu: 1, thread: 222, kind: function-exit, | ||
tsc: 10102 } | ||
|
||
#DEFAULT: Functions with latencies: 2 | ||
#DEFAULT-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#DEFAULT-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#DEFAULT-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#COUNT-ASC: Functions with latencies: 2 | ||
#COUNT-ASC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#COUNT-ASC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#COUNT-ASC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#COUNT-DSC: Functions with latencies: 2 | ||
#COUNT-DSC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#COUNT-DSC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#COUNT-DSC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#MIN-ASC: Functions with latencies: 2 | ||
#MIN-ASC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#MIN-ASC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#MIN-ASC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#MIN-DSC: Functions with latencies: 2 | ||
#MIN-DSC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#MIN-DSC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#MIN-DSC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#MAX-ASC: Functions with latencies: 2 | ||
#MAX-ASC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#MAX-ASC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#MAX-ASC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#MAX-DSC: Functions with latencies: 2 | ||
#MAX-DSC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#MAX-DSC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#MAX-DSC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#SUM-ASC: Functions with latencies: 2 | ||
#SUM-ASC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#SUM-ASC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#SUM-ASC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
|
||
#SUM-DSC: Functions with latencies: 2 | ||
#SUM-DSC-NEXT: funcid count [ min, med, 90p, 99p, max] sum function | ||
#SUM-DSC-NEXT: 1 3 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} | ||
#SUM-DSC-NEXT: 2 2 [{{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}] {{.*}} {{.*}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.