From ea01302a12f7eaa18ee8e87e4e3a2d1254a49cfc Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Mon, 30 Nov 2020 19:17:04 +0100 Subject: [PATCH 1/5] Improved the structure of the IDLE query --- DRAMSys/traceAnalyzer/scripts/metrics.py | 68 +++++++++++++----------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index a8e9f79e..2b7302f9 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -81,41 +81,45 @@ def memory_total(connection): def memory_idle(connection): # This complex query identifies idle times where the DRAM is not used. # The code works also if schedulers are used. - subquery = """ -- The subquery selects all TLM phases and sorts them according to BEGIN_RESP - SELECT - ROW_NUMBER () OVER ( - ORDER BY q.PhaseBegin - ) RowNum, - p.PhaseBegin AS BeginRequest, - p.PhaseEnd AS EndRequest, - q.PhaseBegin AS BeginResponse, - q.PhaseEnd AS EndResponse - - FROM - Phases p, - Phases q - - WHERE - p.PhaseName = "REQ" - AND q.PhaseName = "RESP" - AND p.Transact = q.Transact - """ - - query = """ - SELECT sum(b.BeginRequest - a.EndResponse) as idle FROM - ( - {} - ) AS a, - ( - {} - ) AS b - WHERE - (a.RowNum)=(b.RowNum-1) -- In the list of ordered transactions always compare two adjacent - AND b.BeginRequest > a.EndResponse; -- This makes sure that no negative summands exists - """.format(subquery, subquery) cursor = connection.cursor() + + query = """ + DROP TABLE IF EXISTS phasesInOrder; + """ cursor.execute(query) + + query = """ + -- The temporary table selects all TLM phases and sorts them according to BEGIN_RESP + CREATE TEMPORARY TABLE phasesInOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum, + p.PhaseBegin AS BeginRequest, + p.PhaseEnd AS EndRequest, + q.PhaseBegin AS BeginResponse, + q.PhaseEnd AS EndResponse + FROM + Phases p, + Phases q + WHERE + p.PhaseName = "REQ" AND + q.PhaseName = "RESP" AND + p.Transact = q.Transact; + """ + cursor.execute(query) + + query = """ + + SELECT + sum(b.BeginRequest - a.EndResponse) AS idle + FROM + phasesInOrder AS a, phasesInOrder AS b + WHERE + (a.RowNum)=(b.RowNum-1) AND -- In the list of ordered transactions always compare two adjacent + b.BeginRequest > a.EndResponse; -- This makes sure that no negative summands exists + """ + cursor.execute(query) + idle = cursor.fetchone() if (idle[0] is None): return 0 From a2ae5f8f494dae1f262883dab2177a9d4abac4b3 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Mon, 30 Nov 2020 21:40:34 +0100 Subject: [PATCH 2/5] Added bandwidth root cause analysis --- DRAMSys/traceAnalyzer/scripts/metrics.py | 152 ++++++++++++++++++++++- 1 file changed, 149 insertions(+), 3 deletions(-) diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index 2b7302f9..7c76fad7 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -59,7 +59,6 @@ def trans_with_max_response_latency(connection): result = cursor.fetchone() return result[0] - @metric def memory_active(connection): cursor = connection.cursor() @@ -68,7 +67,6 @@ def memory_active(connection): clk, unit = getClock(connection) return (active[0]/clk) - @metric def memory_total(connection): cursor = connection.cursor() @@ -109,7 +107,6 @@ def memory_idle(connection): cursor.execute(query) query = """ - SELECT sum(b.BeginRequest - a.EndResponse) AS idle FROM @@ -134,6 +131,155 @@ def memory_delayed(connection): idle = memory_idle(connection) return total - active - idle +def check_miss(connection, ID): + cursor = connection.cursor() + query = """SELECT * FROM phases WHERE PhaseName == "ACT" AND Transact = {};""".format(ID) + cursor.execute(query) + result = cursor.fetchone() + if(result != None) : + return True + else: + return False + +def check(connection, gapBegin, gapEnd, b, e): + cursor = connection.cursor() + query = """SELECT Command FROM Transactions WHERE ID = {};""".format(gapBegin) + cursor.execute(query) + begin = cursor.fetchone()[0] + query = """SELECT Command FROM Transactions WHERE ID = {};""".format(gapEnd) + cursor.execute(query) + end = cursor.fetchone()[0] + return (begin == b and end == e) + +@metric +def delayed_reasons(connection): + cursor = connection.cursor() + + # Create a table with sorted Datastrobes: + # (RowNum, ID, Begin, End) + query = """ DROP TABLE IF EXISTS dataStrobesInOrder; """ + cursor.execute(query) + + query = """ + CREATE TEMPORARY TABLE dataStrobesInOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY t.DataStrobeBegin) RowNum, + t.ID as ID, + t.DataStrobeBegin as Begin, + t.DataStrobeEnd as End + + FROM + Transactions t + WHERE + t.DataStrobeBegin <> 0 AND + t.DataStrobeEnd <> 0; + """ + cursor.execute(query) + + # Create a table with phases sorted by BeginResponse: + # (RowNum, BeginRequest, EndRequest, BeginResponse, EndResponse, ID) + query = """ DROP TABLE IF EXISTS phasesInOrder; """ + cursor.execute(query) + + query = """ + CREATE TEMPORARY TABLE phasesInOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum, + p.PhaseBegin AS BeginRequest, + p.PhaseEnd AS EndRequest, + q.PhaseBegin AS BeginResponse, + q.PhaseEnd AS EndResponse, + p.Transact AS ID + FROM + Phases p, + Phases q + WHERE + p.PhaseName = "REQ" + AND q.PhaseName = "RESP" + AND p.Transact = q.Transact; + """ + cursor.execute(query) + + # Create a table with transaction IDs that start a idle time: + # (ID) + query = """ DROP TABLE IF EXISTS idleGaps; """ + cursor.execute(query) + + query = """ + CREATE TEMPORARY TABLE idleGaps AS + SELECT a.ID AS ID + FROM phasesInOrder AS a, phasesInOrder AS b + WHERE + (a.RowNum)=(b.RowNum-1) AND + b.BeginRequest > a.EndResponse; + """ + cursor.execute(query) + + # Create a table which features IDs that form gaps on the databus: + # (gapBeginID, gapEndID) + query = """ DROP TABLE IF EXISTS delayedDataBusGaps; """ + cursor.execute(query) + + query = """ + CREATE TEMPORARY TABLE delayedDataBusGaps AS + SELECT a.ID AS gapBeginID, b.ID AS gapEndID + FROM + dataStrobesInOrder a, + dataStrobesInOrder b + + WHERE + (a.RowNum) = (b.RowNum-1) AND + b.Begin > a.End AND + a.ID not in (SELECT ID FROM idleGaps); + """ + cursor.execute(query) + + query = """ SELECT * FROM delayedDataBusGaps; """; + cursor.execute(query) + + records = cursor.fetchall() + + RR_Miss = 0 + WW_Miss = 0 + RW_Hit = 0 + RW_Miss = 0 + WR_Hit = 0 + WR_Miss = 0 + e = 0 + result = "" + + for row in records: + gapBegin = row[0] + gapEnd = row[1] + + if (check(connection, gapBegin, gapEnd, "R", "R") and check_miss(connection, gapEnd)): + RR_Miss += 1 + elif(check(connection, gapBegin, gapEnd, "W", "W") and check_miss(connection, gapEnd)): + WW_Miss += 1 + elif(check(connection, gapBegin, gapEnd, "R", "W") and (not check_miss(connection, gapEnd))): + RW_Hit += 1 + elif(check(connection, gapBegin, gapEnd, "R", "W") and check_miss(connection, gapEnd)): + RW_Miss += 1 + elif(check(connection, gapBegin, gapEnd, "W", "R") and (not check_miss(connection, gapEnd))): + WR_Hit += 1 + elif(check(connection, gapBegin, gapEnd, "W", "R") and check_miss(connection, gapEnd)): + WR_Miss += 1 + else: + print ("ERROR: This should not happen") + exit(-1) + + total = RR_Miss + WW_Miss + RW_Hit + RW_Miss + WR_Hit + WR_Miss + + RR_Miss /= total + WW_Miss /= total + RW_Hit /= total + RW_Miss /= total + WR_Hit /= total + WR_Miss /= total + + result = "RRM: {}, WWM: {}, RWH: {}, RWM: {}, WRH: {}, WRM: {}".format(RR_Miss, WW_Miss, RW_Hit, RW_Miss, WR_Hit, WR_Miss); + return result + @metric def memory_idle_in_percent(connection): total = memory_total(connection) From 9355e03012aeeb1204528fc1751d30c966bee05c Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Tue, 1 Dec 2020 21:10:54 +0100 Subject: [PATCH 3/5] Changed Delay Reason to RW, WR and Other --- DRAMSys/traceAnalyzer/scripts/metrics.py | 115 ++++++++++------------- 1 file changed, 50 insertions(+), 65 deletions(-) diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index 7c76fad7..63acdd80 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -131,26 +131,6 @@ def memory_delayed(connection): idle = memory_idle(connection) return total - active - idle -def check_miss(connection, ID): - cursor = connection.cursor() - query = """SELECT * FROM phases WHERE PhaseName == "ACT" AND Transact = {};""".format(ID) - cursor.execute(query) - result = cursor.fetchone() - if(result != None) : - return True - else: - return False - -def check(connection, gapBegin, gapEnd, b, e): - cursor = connection.cursor() - query = """SELECT Command FROM Transactions WHERE ID = {};""".format(gapBegin) - cursor.execute(query) - begin = cursor.fetchone()[0] - query = """SELECT Command FROM Transactions WHERE ID = {};""".format(gapEnd) - cursor.execute(query) - end = cursor.fetchone()[0] - return (begin == b and end == e) - @metric def delayed_reasons(connection): cursor = connection.cursor() @@ -166,7 +146,10 @@ def delayed_reasons(connection): ROW_NUMBER () OVER (ORDER BY t.DataStrobeBegin) RowNum, t.ID as ID, t.DataStrobeBegin as Begin, - t.DataStrobeEnd as End + t.DataStrobeEnd as End, + t.TRow as Row, + t.TBank as Bank, + t.Command as Command FROM Transactions t @@ -185,11 +168,11 @@ def delayed_reasons(connection): CREATE TEMPORARY TABLE phasesInOrder AS SELECT ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum, + p.Transact AS ID, p.PhaseBegin AS BeginRequest, p.PhaseEnd AS EndRequest, q.PhaseBegin AS BeginResponse, - q.PhaseEnd AS EndResponse, - p.Transact AS ID + q.PhaseEnd AS EndResponse FROM Phases p, Phases q @@ -222,11 +205,18 @@ def delayed_reasons(connection): query = """ CREATE TEMPORARY TABLE delayedDataBusGaps AS - SELECT a.ID AS gapBeginID, b.ID AS gapEndID + SELECT + a.ID AS gapBeginID, + b.ID AS gapEndID, + a.Row AS gapBeginRow, + b.Row AS gapEndRow, + a.Bank AS gapBeginBank, + b.Bank AS gapEndBank, + a.Command AS gapBeginCommand, + b.Command AS gapEndCommand FROM dataStrobesInOrder a, - dataStrobesInOrder b - + dataStrobesInOrder b WHERE (a.RowNum) = (b.RowNum-1) AND b.Begin > a.End AND @@ -234,50 +224,45 @@ def delayed_reasons(connection): """ cursor.execute(query) - query = """ SELECT * FROM delayedDataBusGaps; """; + # Count RW + query = """ + SELECT + COUNT(*) + FROM delayedDataBusGaps + WHERE + gapBeginCommand = "R" AND + gapEndCommand = "W"; + """; cursor.execute(query) + RW = cursor.fetchone()[0] - records = cursor.fetchall() + # Count WR + query = """ + SELECT + COUNT(*) + FROM delayedDataBusGaps + WHERE + gapBeginCommand = "W" AND + gapEndCommand = "R"; + """; + cursor.execute(query) + WR = cursor.fetchone()[0] - RR_Miss = 0 - WW_Miss = 0 - RW_Hit = 0 - RW_Miss = 0 - WR_Hit = 0 - WR_Miss = 0 - e = 0 - result = "" + # Count All Gaps + query = """ + SELECT + COUNT(*) + FROM delayedDataBusGaps; + """; + cursor.execute(query) + total = cursor.fetchone()[0] + other = total - RW - WR - for row in records: - gapBegin = row[0] - gapEnd = row[1] + RW /= total / 100.0 + WR /= total / 100.0 + other /= total / 100.0 - if (check(connection, gapBegin, gapEnd, "R", "R") and check_miss(connection, gapEnd)): - RR_Miss += 1 - elif(check(connection, gapBegin, gapEnd, "W", "W") and check_miss(connection, gapEnd)): - WW_Miss += 1 - elif(check(connection, gapBegin, gapEnd, "R", "W") and (not check_miss(connection, gapEnd))): - RW_Hit += 1 - elif(check(connection, gapBegin, gapEnd, "R", "W") and check_miss(connection, gapEnd)): - RW_Miss += 1 - elif(check(connection, gapBegin, gapEnd, "W", "R") and (not check_miss(connection, gapEnd))): - WR_Hit += 1 - elif(check(connection, gapBegin, gapEnd, "W", "R") and check_miss(connection, gapEnd)): - WR_Miss += 1 - else: - print ("ERROR: This should not happen") - exit(-1) - - total = RR_Miss + WW_Miss + RW_Hit + RW_Miss + WR_Hit + WR_Miss - - RR_Miss /= total - WW_Miss /= total - RW_Hit /= total - RW_Miss /= total - WR_Hit /= total - WR_Miss /= total - - result = "RRM: {}, WWM: {}, RWH: {}, RWM: {}, WRH: {}, WRM: {}".format(RR_Miss, WW_Miss, RW_Hit, RW_Miss, WR_Hit, WR_Miss); + result = "RW: {}, WR: {}, Other: {}".format(RW, WR, other); return result @metric From e9ccfaade7345cb7516b0cdb981face0dd6e27d2 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Wed, 2 Dec 2020 10:00:15 +0100 Subject: [PATCH 4/5] Added RR and WW Miss --- DRAMSys/traceAnalyzer/scripts/metrics.py | 38 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index 63acdd80..d3ba866b 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -208,10 +208,6 @@ def delayed_reasons(connection): SELECT a.ID AS gapBeginID, b.ID AS gapEndID, - a.Row AS gapBeginRow, - b.Row AS gapEndRow, - a.Bank AS gapBeginBank, - b.Bank AS gapEndBank, a.Command AS gapBeginCommand, b.Command AS gapEndCommand FROM @@ -248,6 +244,34 @@ def delayed_reasons(connection): cursor.execute(query) WR = cursor.fetchone()[0] + # Count RR Miss + query = """ + SELECT + COUNT(*) + FROM delayedDataBusGaps d, Phases p + WHERE + d.gapBeginCommand = "R" AND + d.gapEndCommand = "R" AND + p.Transact = d.gapEndID AND + PhaseName = "ACT"; + """; + cursor.execute(query) + RRM = cursor.fetchone()[0] + + # Count WW Miss + query = """ + SELECT + COUNT(*) + FROM delayedDataBusGaps d, Phases p + WHERE + d.gapBeginCommand = "W" AND + d.gapEndCommand = "W" AND + p.Transact = d.gapEndID AND + PhaseName = "ACT"; + """; + cursor.execute(query) + WWM = cursor.fetchone()[0] + # Count All Gaps query = """ SELECT @@ -256,13 +280,15 @@ def delayed_reasons(connection): """; cursor.execute(query) total = cursor.fetchone()[0] - other = total - RW - WR + other = total - RW - WR - RRM - WWM RW /= total / 100.0 WR /= total / 100.0 + RRM /= total / 100.0 + WWM /= total / 100.0 other /= total / 100.0 - result = "RW: {}, WR: {}, Other: {}".format(RW, WR, other); + result = "RW: {}, WR: {}, RRM: {}, WWM: {}, Other: {}".format(RW, WR, RRM, WWM, other); return result @metric From ccca87d63302884b23efcaae7ff4f681f09933cd Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Thu, 3 Dec 2020 14:28:18 +0100 Subject: [PATCH 5/5] Corrected idle phases calculation. --- DRAMSys/traceAnalyzer/scripts/metrics.py | 207 ++++++++++++++--------- 1 file changed, 125 insertions(+), 82 deletions(-) diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index d3ba866b..03f7d186 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -79,50 +79,66 @@ def memory_total(connection): def memory_idle(connection): # This complex query identifies idle times where the DRAM is not used. # The code works also if schedulers are used. - + cursor = connection.cursor() - + + # Create a table with transactions sorted by BeginRequest: + # (RowNum, BeginRequest) + query = """ DROP TABLE IF EXISTS transactionsInRequestOrder; """ + cursor.execute(query) + query = """ - DROP TABLE IF EXISTS phasesInOrder; + CREATE TEMPORARY TABLE transactionsInRequestOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY p.PhaseBegin) RowNum, + p.PhaseBegin AS BeginRequest + FROM + Phases p + WHERE + p.PhaseName = "REQ"; """ cursor.execute(query) - + + # Create a table with transactions sorted by BeginResponse: + # (RowNum, ID, EndResponse) + query = """ DROP TABLE IF EXISTS transactionsInResponseOrder; """ + cursor.execute(query) + query = """ - -- The temporary table selects all TLM phases and sorts them according to BEGIN_RESP - CREATE TEMPORARY TABLE phasesInOrder AS + CREATE TEMPORARY TABLE transactionsInResponseOrder AS SELECT ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum, - p.PhaseBegin AS BeginRequest, - p.PhaseEnd AS EndRequest, - q.PhaseBegin AS BeginResponse, + q.Transact AS ID, q.PhaseEnd AS EndResponse FROM - Phases p, Phases q WHERE - p.PhaseName = "REQ" AND - q.PhaseName = "RESP" AND - p.Transact = q.Transact; + q.PhaseName = "RESP"; """ cursor.execute(query) + # Sum up the idle times: query = """ - SELECT - sum(b.BeginRequest - a.EndResponse) AS idle - FROM - phasesInOrder AS a, phasesInOrder AS b + SELECT + sum(c.BeginRequest - b.EndResponse) AS idle + FROM + transactionsInRequestOrder AS a, transactionsInResponseOrder AS b, transactionsInRequestOrder AS c WHERE - (a.RowNum)=(b.RowNum-1) AND -- In the list of ordered transactions always compare two adjacent - b.BeginRequest > a.EndResponse; -- This makes sure that no negative summands exists + a.RowNum=b.RowNum AND + c.RowNum=(a.RowNum+1) AND + c.BeginRequest>b.EndResponse; """ - cursor.execute(query) - + cursor.execute(query) idle = cursor.fetchone() + + cursor.execute(""" SELECT min(PhaseBegin) FROM Phases WHERE PhaseName = 'REQ' """) + idle_start = cursor.fetchone() + clk, unit = getClock(connection) + if (idle[0] is None): - return 0 + return (idle_start[0] / clk) else: - clk, unit = getClock(connection) - return (idle[0]/clk) + return ((idle[0] + idle_start[0]) / clk) @metric def memory_delayed(connection): @@ -141,48 +157,58 @@ def delayed_reasons(connection): cursor.execute(query) query = """ - CREATE TEMPORARY TABLE dataStrobesInOrder AS - SELECT - ROW_NUMBER () OVER (ORDER BY t.DataStrobeBegin) RowNum, - t.ID as ID, - t.DataStrobeBegin as Begin, - t.DataStrobeEnd as End, - t.TRow as Row, - t.TBank as Bank, - t.Command as Command - - FROM - Transactions t - WHERE - t.DataStrobeBegin <> 0 AND - t.DataStrobeEnd <> 0; + CREATE TEMPORARY TABLE dataStrobesInOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY t.DataStrobeBegin) RowNum, + t.ID as ID, + t.DataStrobeBegin as Begin, + t.DataStrobeEnd as End, + t.TRow as Row, + t.TBank as Bank, + t.Command as Command + FROM + Transactions t + WHERE + t.DataStrobeBegin <> 0 AND + t.DataStrobeEnd <> 0; """ cursor.execute(query) - - # Create a table with phases sorted by BeginResponse: - # (RowNum, BeginRequest, EndRequest, BeginResponse, EndResponse, ID) - query = """ DROP TABLE IF EXISTS phasesInOrder; """ + + # Create a table with transactions sorted by BeginRequest: + # (RowNum, BeginRequest) + query = """ DROP TABLE IF EXISTS transactionsInRequestOrder; """ cursor.execute(query) - + query = """ - CREATE TEMPORARY TABLE phasesInOrder AS - SELECT - ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum, - p.Transact AS ID, - p.PhaseBegin AS BeginRequest, - p.PhaseEnd AS EndRequest, - q.PhaseBegin AS BeginResponse, - q.PhaseEnd AS EndResponse - FROM - Phases p, - Phases q - WHERE - p.PhaseName = "REQ" - AND q.PhaseName = "RESP" - AND p.Transact = q.Transact; + CREATE TEMPORARY TABLE transactionsInRequestOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY p.PhaseBegin) RowNum, + p.PhaseBegin AS BeginRequest + FROM + Phases p + WHERE + p.PhaseName = "REQ"; """ cursor.execute(query) - + + # Create a table with transactions sorted by BeginResponse: + # (RowNum, ID, EndResponse) + query = """ DROP TABLE IF EXISTS transactionsInResponseOrder; """ + cursor.execute(query) + + query = """ + CREATE TEMPORARY TABLE transactionsInResponseOrder AS + SELECT + ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum, + q.Transact AS ID, + q.PhaseEnd AS EndResponse + FROM + Phases q + WHERE + q.PhaseName = "RESP"; + """ + cursor.execute(query) + # Create a table with transaction IDs that start a idle time: # (ID) query = """ DROP TABLE IF EXISTS idleGaps; """ @@ -190,11 +216,14 @@ def delayed_reasons(connection): query = """ CREATE TEMPORARY TABLE idleGaps AS - SELECT a.ID AS ID - FROM phasesInOrder AS a, phasesInOrder AS b + SELECT + b.ID AS ID + FROM + transactionsInRequestOrder AS a, transactionsInResponseOrder AS b, transactionsInRequestOrder AS c WHERE - (a.RowNum)=(b.RowNum-1) AND - b.BeginRequest > a.EndResponse; + a.RowNum=b.RowNum AND + c.RowNum=(a.RowNum+1) AND + c.BeginRequest>b.EndResponse; """ cursor.execute(query) @@ -204,7 +233,7 @@ def delayed_reasons(connection): cursor.execute(query) query = """ - CREATE TEMPORARY TABLE delayedDataBusGaps AS + CREATE TEMPORARY TABLE delayedDataBusGaps AS SELECT a.ID AS gapBeginID, b.ID AS gapEndID, @@ -236,7 +265,8 @@ def delayed_reasons(connection): query = """ SELECT COUNT(*) - FROM delayedDataBusGaps + FROM + delayedDataBusGaps WHERE gapBeginCommand = "W" AND gapEndCommand = "R"; @@ -246,28 +276,40 @@ def delayed_reasons(connection): # Count RR Miss query = """ - SELECT - COUNT(*) - FROM delayedDataBusGaps d, Phases p - WHERE - d.gapBeginCommand = "R" AND - d.gapEndCommand = "R" AND - p.Transact = d.gapEndID AND - PhaseName = "ACT"; + SELECT COUNT(*) FROM + ( + SELECT + COUNT(*) + FROM + delayedDataBusGaps d, Phases p + WHERE + d.gapBeginCommand = "R" AND + d.gapEndCommand = "R" AND + p.Transact = d.gapEndID AND + p.PhaseName = "ACT" + GROUP BY + d.gapBeginID + ) """; cursor.execute(query) RRM = cursor.fetchone()[0] # Count WW Miss query = """ - SELECT - COUNT(*) - FROM delayedDataBusGaps d, Phases p - WHERE - d.gapBeginCommand = "W" AND - d.gapEndCommand = "W" AND - p.Transact = d.gapEndID AND - PhaseName = "ACT"; + SELECT COUNT(*) FROM + ( + SELECT + COUNT(*) + FROM + delayedDataBusGaps d, Phases p + WHERE + d.gapBeginCommand = "W" AND + d.gapEndCommand = "W" AND + p.Transact = d.gapEndID AND + p.PhaseName = "ACT" + GROUP BY + d.gapBeginID + ) """; cursor.execute(query) WWM = cursor.fetchone()[0] @@ -280,6 +322,7 @@ def delayed_reasons(connection): """; cursor.execute(query) total = cursor.fetchone()[0] + other = total - RW - WR - RRM - WWM RW /= total / 100.0