From owner-svn-src-all@FreeBSD.ORG Tue Jan 20 12:33:04 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECC5A1065672; Tue, 20 Jan 2009 12:33:04 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D0D1D8FC0C; Tue, 20 Jan 2009 12:33:04 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0KCX4Fu045316; Tue, 20 Jan 2009 12:33:04 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0KCX4u5045315; Tue, 20 Jan 2009 12:33:04 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <200901201233.n0KCX4u5045315@svn.freebsd.org> From: Jeff Roberson Date: Tue, 20 Jan 2009 12:33:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187471 - head/tools/sched X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jan 2009 12:33:05 -0000 Author: jeff Date: Tue Jan 20 12:33:04 2009 New Revision: 187471 URL: http://svn.freebsd.org/changeset/base/187471 Log: - Permit timestamps to be as far as 2048 ticks apart before we complain about invalid timestamps. Nehalem CPUs seem to be synchronized but only within a fraction of a microsecond. - Make the Counter code more flexible to poor timestamps. In general we now complain a lot but render as much as we can. - Change the scaler behavior so it works better with very long and very short traces. We now set the maximum scale such that it properly displays the entire file by default and doesn't permit zooming out beyond the file. This improves other awkward navigation behavior. The interval is now set very small which can't be achieved by simply dragging the mouse. Clicking to the left of or right of the scaler bar will produce increments of a single, very small, interval now. Sponsored by: Nokia Modified: head/tools/sched/schedgraph.py Modified: head/tools/sched/schedgraph.py ============================================================================== --- head/tools/sched/schedgraph.py Tue Jan 20 12:07:49 2009 (r187470) +++ head/tools/sched/schedgraph.py Tue Jan 20 12:33:04 2009 (r187471) @@ -162,15 +162,12 @@ def ticks2sec(ticks): class Scaler(Frame): def __init__(self, master, target): Frame.__init__(self, master) - self.scale = Scale(self, command=self.scaleset, - from_=1000, to_=10000000, orient=HORIZONTAL, - resolution=1000) + self.scale = None + self.target = target self.label = Label(self, text="Ticks per pixel") self.label.pack(side=LEFT) - self.scale.pack(fill="both", expand=1) - self.target = target - self.scale.set(target.scaleget()) - self.initialized = 1 + self.resolution = 100 + self.setmax(10000) def scaleset(self, value): self.target.scaleset(int(value)) @@ -178,6 +175,20 @@ class Scaler(Frame): def set(self, value): self.scale.set(value) + def setmax(self, value): + # + # We can't reconfigure the to_ value so we delete the old + # window and make a new one when we resize. + # + if (self.scale != None): + self.scale.pack_forget() + self.scale.destroy() + self.scale = Scale(self, command=self.scaleset, + from_=100, to_=value, orient=HORIZONTAL, + resolution=self.resolution) + self.scale.pack(fill="both", expand=1) + self.scale.set(self.target.scaleget()) + class Status(Frame): def __init__(self, master): Frame.__init__(self, master) @@ -726,6 +737,11 @@ class CountEvent(Event): return (xpos) color = colormap.lookup("count") self.duration = duration = next.timestamp - self.timestamp + if (duration < 0): + duration = 0 + print "Unsynchronized timestamp" + print self.cpu, self.timestamp + print next.cpu, next.timestamp self.attrs.insert(0, ("count", self.count)) self.attrs.insert(1, ("duration", ticks2sec(duration))) delta = duration / canvas.ratio @@ -882,6 +898,7 @@ class KTRFile: self.crit = {} self.stathz = 0 self.eventcnt = 0 + self.taghash = {} self.parse(file) self.fixup() @@ -956,7 +973,8 @@ class KTRFile: if (dat == None): dat = dat1 if (self.checkstamp(timestamp) == 0): - print "Bad timestamp at", lineno, ":", line, + print "Bad timestamp at", lineno, ":", + print cpu, timestamp continue # # Build the table of optional attributes @@ -1021,20 +1039,22 @@ class KTRFile: timestamp = int(timestamp) if (self.timestamp_f == None): self.timestamp_f = timestamp; - if (self.timestamp_l != None and timestamp > self.timestamp_l): + if (self.timestamp_l != None and + timestamp -2048> self.timestamp_l): return (0) self.timestamp_l = timestamp; return (1) def makeid(self, group, id, type): - for source in sources: - if (source.name == id and source.group == group): - return source + tag = group + id + if (self.taghash.has_key(tag)): + return self.taghash[tag] if (type == "counter"): source = Counter(group, id) else: source = EventSource(group, id) sources.append(source) + self.taghash[tag] = source return (source) def findid(self, id): @@ -1053,7 +1073,7 @@ class KTRFile: return int(clockfreq * oneghz) # Check for a discovered clock - if (self.stathz != None): + if (self.stathz != 0): return (self.timespan() / self.ticks[0]) * int(self.stathz) # Pretend we have a 1ns clock print "WARNING: No clock discovered and no frequency ", @@ -1313,8 +1333,16 @@ class SchedGraph(Frame): self.names.draw() self.display.draw() self.status.startup("") - self.scale.set(250000) + # + # Configure scale related values + # + scalemax = ktrfile.timespan() / int(self.display["width"]) + width = int(root.geometry().split('x')[0]) + self.constwidth = width - int(self.display["width"]) + self.scale.setmax(scalemax) + self.scale.set(scalemax) self.display.xview_moveto(0) + self.bind("", self.resize) def mousepress(self, event): self.clicksource = self.sourceat(event.y) @@ -1452,8 +1480,7 @@ class SchedGraph(Frame): source.hidden = 0 size += sz idx += 1 - self.names.updatescroll() - self.display.updatescroll() + self.updatescroll() self.status.set("") # @@ -1496,8 +1523,7 @@ class SchedGraph(Frame): if (nstart >= stop): break; self.sourceshift(source, -size) - self.names.updatescroll() - self.display.updatescroll() + self.updatescroll() self.status.set("") def sourcehide(self, source): @@ -1530,8 +1556,7 @@ class SchedGraph(Frame): if (nstart < start): continue; self.sourceshift(source, off) - self.names.updatescroll() - self.display.updatescroll() + self.updatescroll() self.status.set("") def sourceat(self, ypos): @@ -1551,6 +1576,15 @@ class SchedGraph(Frame): self.names.yview(*args) self.display.yview(*args) + def resize(self, *args): + width = int(root.geometry().split('x')[0]) + scalemax = ktrfile.timespan() / (width - self.constwidth) + self.scale.setmax(scalemax) + + def updatescroll(self): + self.names.updatescroll() + self.display.updatescroll() + def setcolor(self, tag, color): self.display.setcolor(tag, color)