forked from andikleen/pmu-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsx_metrics.py
81 lines (74 loc) · 2.58 KB
/
tsx_metrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# TSX metrics
#
# XXX force all these into a single group
# XXX: force % in caller
def TXCycles(EV, level):
return EV("cpu/cycles-t/", level) / EV("cycles", level)
class TransactionalCycles:
name = "Transactional cycles"
desc = """
Percent cycles spent in a transaction. When low or zero either the program
does not use locks (or other transactions), or the locks are not enabled with lock elision."""
subplot = "TSX"
unit = "%"
sample = ["mem_uops_retired.lock_loads"]
server = True
def compute(self, EV):
try:
self.val = TXCycles(EV, 1) * 100.
self.thresh = (self.val >= 0.01)
except ZeroDivisionError:
self.val = 0
self.thresh = False
class AbortedCycles:
name = "Aborted cycles"
desc = """
Percent cycles wasted in transaction aborts. When a significant part of the transactional cycles
start sampling for abort causes."""
subplot = "TSX"
unit = "%"
sample = ["cpu/tx-abort/pp", "cpu/hle-abort/pp"]
server = True
def compute(self, EV):
try:
self.val = ((EV("cpu/cycles-t/", 1) - EV("cpu/cycles-ct/", 1)) / EV("cycles", 1)) * 100.
self.thresh = (self.val >= 0.01)
except ZeroDivisionError:
self.val = 0
self.thresh = False
class AverageRTM:
name = "Average RTM transaction length"
desc = """
Average RTM transaction length. Assumes most transactions are RTM.
When low consider increasing the size of the critical sections to lower overhead."""
subplot = "TSX Latencies"
unit = "cycles"
server = True
def compute(self, EV):
try:
self.val = EV("cpu/cycles-t/", 1) / EV("RTM_RETIRED.START", 1)
self.thresh = TXCycles(EV, 1) >= 0.01 and self.val > 0
except ZeroDivisionError:
self.val = 0
self.thresh = False
class AverageHLE:
name = "Average HLE transaction length"
desc = """
Average HLE transaction length. Assumes most transactions are HLE.
When low consider increasing the size of the critical sections to lower overhead."""
subplot = "TSX Latencies"
unit = "cycles"
def compute(self, EV):
try:
self.val = EV("cpu/cycles-t/", 1) / EV("HLE_RETIRED.START", 1)
self.thresh = TXCycles(EV, 1) >= 0.01 and self.val > 0
except ZeroDivisionError:
self.val = 0
self.thresh = False
class Setup:
def __init__(self, r):
r.force_metric(TransactionalCycles())
r.force_metric(AbortedCycles())
r.force_metric(AverageRTM())
#r.force_metric(AverageHLE())