diff options
author | Mac Mollison <mollison@cs.unc.edu> | 2010-03-26 14:27:38 -0400 |
---|---|---|
committer | Mac Mollison <mollison@cs.unc.edu> | 2010-03-26 14:27:38 -0400 |
commit | d486ddadacd9e9308e64c251388ff262d4b2d198 (patch) | |
tree | 25770a1f024aaa67062771418d5fd85426a059fd | |
parent | 58d168e52c3de9f3a53d0aea802be5cab492ade6 (diff) |
Track and print triggering events with inversions
-rw-r--r-- | unit_trace/gedf_test.py | 33 | ||||
-rw-r--r-- | unit_trace/stdout_printer.py | 9 |
2 files changed, 32 insertions, 10 deletions
diff --git a/unit_trace/gedf_test.py b/unit_trace/gedf_test.py index 3f4e150..f3088ac 100644 --- a/unit_trace/gedf_test.py +++ b/unit_trace/gedf_test.py | |||
@@ -27,17 +27,27 @@ def gedf_test(stream): | |||
27 | # is updated. | 27 | # is updated. |
28 | last_time = None | 28 | last_time = None |
29 | 29 | ||
30 | # First event for the latest timestamp. This is used to match up | ||
31 | # inversion starts and ends with the first event from the previous | ||
32 | # timestamp, which is the first event that could have triggered | ||
33 | # the inversion start or end. | ||
34 | first_event_this_timestamp = 0 | ||
35 | |||
30 | for record in stream: | 36 | for record in stream: |
31 | if record.record_type != "event": | 37 | if record.record_type != "event": |
32 | if record.record_type == "meta" and record.type_name == "num_cpus": | 38 | if record.record_type == "meta" and record.type_name == "num_cpus": |
33 | m = record.num_cpus | 39 | m = record.num_cpus |
34 | continue | 40 | continue |
35 | 41 | ||
42 | # Bookkeeping iff the timestamp has moved forward. | ||
36 | # Check for inversion starts and ends and yield them. | 43 | # Check for inversion starts and ends and yield them. |
37 | # Only to the check when time has moved forward. | 44 | # (It is common to have records with simultaneous timestamps, |
38 | # (It is common to have records with simultaneous timestamps.) | 45 | # so we only check when the time has moved forward) |
46 | # Also, need to update the first_event_this_timestamp variable | ||
39 | if last_time is not None and last_time != record.when: | 47 | if last_time is not None and last_time != record.when: |
40 | errors = _gedf_check(eligible,on_cpu,last_time,m) | 48 | errors = _gedf_check(eligible,on_cpu,last_time,m, |
49 | first_event_this_timestamp) | ||
50 | first_event_this_timestamp = record.id | ||
41 | for error in errors: | 51 | for error in errors: |
42 | yield error | 52 | yield error |
43 | 53 | ||
@@ -89,25 +99,29 @@ class Job(object): | |||
89 | self.inversion_start = None | 99 | self.inversion_start = None |
90 | self.inversion_end = None | 100 | self.inversion_end = None |
91 | self.inversion_start_id = None | 101 | self.inversion_start_id = None |
102 | self.inversion_start_triggering_event_id = None | ||
92 | def __str__(self): | 103 | def __str__(self): |
93 | return "(%d.%d:%d)" % (self.pid,self.job,self.deadline) | 104 | return "(%d.%d:%d)" % (self.pid,self.job,self.deadline) |
94 | 105 | ||
95 | # G-EDF errors: the start or end of an inversion | 106 | # G-EDF errors: the start or end of an inversion |
96 | class Error(object): | 107 | class Error(object): |
97 | id = 0 | 108 | id = 0 |
98 | def __init__(self, job, eligible, on_cpu): | 109 | def __init__(self, job, eligible, on_cpu,first_event_this_timestamp): |
99 | Error.id += 1 | 110 | Error.id += 1 |
100 | self.id = Error.id | 111 | self.id = Error.id |
101 | self.job = copy.copy(job) | 112 | self.job = copy.copy(job) |
102 | self.eligible = copy.copy(eligible) | 113 | self.eligible = copy.copy(eligible) |
103 | self.on_cpu = copy.copy(on_cpu) | 114 | self.on_cpu = copy.copy(on_cpu) |
104 | self.record_type = 'error' | 115 | self.record_type = 'error' |
116 | self.triggering_event_id = first_event_this_timestamp | ||
105 | if job.inversion_end is None: | 117 | if job.inversion_end is None: |
106 | self.type_name = 'inversion_start' | 118 | self.type_name = 'inversion_start' |
107 | job.inversion_start_id = self.id | 119 | job.inversion_start_id = self.id |
120 | job.inversion_start_triggering_event_id = self.triggering_event_id | ||
108 | else: | 121 | else: |
109 | self.type_name = 'inversion_end' | 122 | self.type_name = 'inversion_end' |
110 | self.inversion_start_id = job.inversion_start_id | 123 | self.inversion_start_id = job.inversion_start_id |
124 | self.inversion_start_triggering_event_id = job.inversion_start_triggering_event_id | ||
111 | 125 | ||
112 | # Returns the position of a Job in a list, or None | 126 | # Returns the position of a Job in a list, or None |
113 | def _find_job(record,list): | 127 | def _find_job(record,list): |
@@ -117,7 +131,7 @@ def _find_job(record,list): | |||
117 | return None | 131 | return None |
118 | 132 | ||
119 | # Return records for any inversion_starts and inversion_ends | 133 | # Return records for any inversion_starts and inversion_ends |
120 | def _gedf_check(eligible,on_cpu,when,m): | 134 | def _gedf_check(eligible,on_cpu,when,m,first_event_this_timestamp): |
121 | 135 | ||
122 | # List of error records to be returned | 136 | # List of error records to be returned |
123 | errors = [] | 137 | errors = [] |
@@ -142,13 +156,15 @@ def _gedf_check(eligible,on_cpu,when,m): | |||
142 | # It's not running and an inversion_start has not been recorded | 156 | # It's not running and an inversion_start has not been recorded |
143 | if job not in on_cpu and job.inversion_start is None: | 157 | if job not in on_cpu and job.inversion_start is None: |
144 | job.inversion_start = when | 158 | job.inversion_start = when |
145 | errors.append(Error(job, eligible, on_cpu)) | 159 | errors.append(Error(job, eligible, on_cpu, |
160 | first_event_this_timestamp)) | ||
146 | 161 | ||
147 | # It is running and an inversion_start exists (i.e. it it still | 162 | # It is running and an inversion_start exists (i.e. it it still |
148 | # marked as being inverted) | 163 | # marked as being inverted) |
149 | elif job in on_cpu and job.inversion_start is not None: | 164 | elif job in on_cpu and job.inversion_start is not None: |
150 | job.inversion_end = when | 165 | job.inversion_end = when |
151 | errors.append(Error(job, eligible, on_cpu)) | 166 | errors.append(Error(job, eligible, on_cpu, |
167 | first_event_this_timestamp)) | ||
152 | job.inversion_start = None | 168 | job.inversion_start = None |
153 | job.inversion_end = None | 169 | job.inversion_end = None |
154 | 170 | ||
@@ -162,7 +178,8 @@ def _gedf_check(eligible,on_cpu,when,m): | |||
162 | # marked as being inverted) | 178 | # marked as being inverted) |
163 | if job not in on_cpu and job.inversion_start is not None: | 179 | if job not in on_cpu and job.inversion_start is not None: |
164 | job.inversion_end = when | 180 | job.inversion_end = when |
165 | errors.append(Error(job, eligible, on_cpu)) | 181 | errors.append(Error(job, eligible, on_cpu, |
182 | first_event_this_timestamp)) | ||
166 | job.inversion_start = None | 183 | job.inversion_start = None |
167 | job.inversion_end = None | 184 | job.inversion_end = None |
168 | 185 | ||
diff --git a/unit_trace/stdout_printer.py b/unit_trace/stdout_printer.py index 4fea95a..a56acce 100644 --- a/unit_trace/stdout_printer.py +++ b/unit_trace/stdout_printer.py | |||
@@ -33,8 +33,9 @@ def _print_event(record): | |||
33 | print "Time: %d" % (record.when) | 33 | print "Time: %d" % (record.when) |
34 | 34 | ||
35 | def _print_inversion_start(record): | 35 | def _print_inversion_start(record): |
36 | print "Inversion Record IDs: (%d, U)" % (record.id) | ||
37 | print "Type: %s" % ("Inversion start") | 36 | print "Type: %s" % ("Inversion start") |
37 | print "Inversion Record IDs: (%d, U)" % (record.id) | ||
38 | print "Triggering Event IDs: (%d, U)" % (record.triggering_event_id) | ||
38 | print "Time: %d" % (record.job.inversion_start) | 39 | print "Time: %d" % (record.job.inversion_start) |
39 | print "Job: %d.%d" % (record.job.pid,record.job.job) | 40 | print "Job: %d.%d" % (record.job.pid,record.job.job) |
40 | print "Deadline: %d" % (record.job.deadline) | 41 | print "Deadline: %d" % (record.job.deadline) |
@@ -48,8 +49,12 @@ def _print_inversion_start(record): | |||
48 | print #newline | 49 | print #newline |
49 | 50 | ||
50 | def _print_inversion_end(record): | 51 | def _print_inversion_end(record): |
51 | print "Inversion record IDs: (%d, %d)" % (record.inversion_start_id,record.id) | ||
52 | print "Type: %s" % ("Inversion end") | 52 | print "Type: %s" % ("Inversion end") |
53 | print "Inversion record IDs: (%d, %d)" % (record.inversion_start_id, | ||
54 | record.id) | ||
55 | print("Triggering Event IDs: (%d, %d)" % | ||
56 | (record.inversion_start_triggering_event_id, | ||
57 | record.triggering_event_id)) | ||
53 | print "Time: %d" % (record.job.inversion_end) | 58 | print "Time: %d" % (record.job.inversion_end) |
54 | print "Duration: %d" % ( | 59 | print "Duration: %d" % ( |
55 | record.job.inversion_end - record.job.inversion_start) | 60 | record.job.inversion_end - record.job.inversion_start) |