Leon Matthes uploaded a new version of CogTools to project VM Maker: http://source.squeak.org/VMMaker/CogTools.threaded-LM.99.mcz
==================== Summary ====================
Name: CogTools.threaded-LM.99 Author: LM Time: 21 December 2023, 4:31:24.557954 pm UUID: bd415344-8dbd-4777-b766-0b4fe6928662 Ancestors: CogTools.threaded-LM.98
Improve ThreadInspector by: 1. increased log size 2. a new plot series line type #steppedHorizontal. 3. a zoom stack to zoom out to the previous zoom level.
=============== Diff against CogTools.threaded-LM.98 ===============
Item was changed: ----- Method: PlotSeries>>drawOn: (in category 'drawing') ----- drawOn: aCanvas points isEmpty ifTrue: [^ self]. "" drawArea ifTrue: ["" type == #straightened ifTrue: [self drawStraightenedAreaOn: aCanvas]. type == #stepped + ifTrue: [self drawSteppedAreaOn: aCanvas]. + type == #steppedHorizontal + ifTrue: [self drawSteppedHorizontalLineOn: aCanvas]]. - ifTrue: [self drawSteppedAreaOn: aCanvas]]. drawLine ifTrue: ["" type == #straightened ifTrue: [self drawStraightenedLineOn: aCanvas]. type == #stepped ifTrue: [self drawSteppedLineOn: aCanvas]]. drawPoints ifTrue: [self drawPointsOn: aCanvas]!
Item was added: + ----- Method: PlotSeries>>drawSteppedHorizontalLineOn: (in category 'drawing') ----- + drawSteppedHorizontalLineOn: aCanvas + | lineColor lastScaledPoint | + lineColor := self lineColor. + lastScaledPoint := nil. + points + do: [:point | + | scaledPoint | + scaledPoint := point scaledPoint. + lastScaledPoint + ifNotNil: [aCanvas + line: lastScaledPoint + to: scaledPoint x @ lastScaledPoint y + width: width + color: lineColor.]. + lastScaledPoint := scaledPoint]!
Item was changed: ----- Method: PlotSeries>>drawSteppedLineOn: (in category 'drawing') ----- drawSteppedLineOn: aCanvas | lineColor lastScaledPoint | lineColor := self lineColor. lastScaledPoint := nil. points do: [:point | | scaledPoint | scaledPoint := point scaledPoint. lastScaledPoint ifNotNil: [""aCanvas line: lastScaledPoint to: scaledPoint x @ lastScaledPoint y width: width color: lineColor. + "aCanvas - aCanvas line: scaledPoint x @ lastScaledPoint y to: scaledPoint width: width + color: lineColor"]. - color: lineColor]. lastScaledPoint := scaledPoint]!
Item was changed: Model subclass: #ThreadInspector + instanceVariableNames: 'startTime ownerLog graph currentStartTime currentEndTime zoomStack' - instanceVariableNames: 'startTime ownerLog graph currentStartTime currentEndTime' classVariableNames: '' poolDictionaries: '' category: 'CogTools-ThreadInspector'!
Item was changed: + ----- Method: ThreadInspector>>afterBuildWith: (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>afterBuildWith: (in category 'as yet unclassified') ----- afterBuildWith: builder
self initializeGraph. self plotGraphFrom: startTime to: self ownerLog last timestamp. (builder widgetAt: #PlotViewport) addMorph: graph fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1)).!
Item was changed: + ----- Method: ThreadInspector>>buildWith: (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>buildWith: (in category 'as yet unclassified') ----- buildWith: builder
|windowSpec window| windowSpec := builder pluggableWindowSpec new. windowSpec model: self; label: 'VM Owner Inspector'; extent: 400@400; children: (self windowMemberSpecsFor: builder). window := builder build: windowSpec. self afterBuildWith: builder. ^ window!
Item was changed: ----- Method: ThreadInspector>>getOwnerLogFromVM (in category 'accessing') ----- getOwnerLogFromVM
|bytes numElements bigEndian| + bytes := (ByteArray new: 3*8*1024*100 "The log is currently 100Ki entries"). - bytes := (ByteArray new: 3*8*1024). numElements := self primitiveGetOwnerLog: bytes. bigEndian := Smalltalk endianness = #big. self assert: Smalltalk wordSize = 8. "TODO: Decode 32-bit VM log"
^ (0 to: numElements - 1) collect: [:index | |bytesOffset| bytesOffset := index * 24. CogVMOwnerLog new timestamp: (bytes long64At: bytesOffset + 1 bigEndian: bigEndian); "+1 because Smalltalk is 1-indexed" vmOwner: (bytes long64At: bytesOffset + 9 bigEndian: bigEndian); successfulSwitch: (bytes long64At: bytesOffset + 17 bigEndian: bigEndian) ~= 0; yourself].!
Item was changed: + ----- Method: ThreadInspector>>initialize (in category 'initialize-release') ----- - ----- Method: ThreadInspector>>initialize (in category 'as yet unclassified') ----- initialize
self currentStartTime: 0. self currentEndTime: 1. + self zoomStack: Stack new.! - !
Item was changed: ----- Method: ThreadInspector>>initializeGraph (in category 'plotting') ----- initializeGraph
graph := ThreadInspectorPlotMorph new model: self; yourself. graph series: #vmOwner color: Color green; series: #vmOwner description: 'vm owner'; + series: #vmOwner type: #steppedHorizontal; + series: #vmOwner width: 2 px. - series: #vmOwner type: #stepped.
graph series: #failedLocks color: Color red; series: #failedLocks description: 'failed locking attempts'; series: #failedLocks drawLine: false; + series: #failedLocks width: 3 px. - series: #failedLocks width: 2. graph xAxisFormatter: [:value | ((value - (self currentStartTime)/ 1000) asFloat printShowingMaxDecimalPlaces: 4), ' ms'].
"make sure we always have at least -1, 0 and 1 in view, even if there were no owner switches to them." graph minPoint y > -1 ifTrue: [graph limitMinY: -1]. graph maxPoint y < 1 ifTrue: [graph limitMaxY: 1].!
Item was changed: + ----- Method: ThreadInspector>>menuBarHeight (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>menuBarHeight (in category 'as yet unclassified') ----- menuBarHeight
^ Preferences standardButtonFont height * 3!
Item was changed: + ----- Method: ThreadInspector>>menuBarSpec: (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>menuBarSpec: (in category 'as yet unclassified') ----- menuBarSpec: builder
^ builder pluggablePanelSpec new model: self; frame: (LayoutFrame new leftFraction: 0; rightFraction: 1; topFraction: 1 offset: self menuBarHeight negated; bottomFraction: 1; yourself); children: { builder pluggableButtonSpec new model: self; action: #zoomOut; label: 'Zoom out'; frame: LayoutFrame fullFrame; yourself. }!
Item was changed: + ----- Method: ThreadInspector>>open (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>open (in category 'as yet unclassified') ----- open
(self buildWith: ToolBuilder default) openInWorld.!
Item was changed: + ----- Method: ThreadInspector>>plotSpec: (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>plotSpec: (in category 'as yet unclassified') ----- plotSpec: builder
^ builder pluggablePanelSpec new model: self; frame: (LayoutFrame new leftFraction: 0; topFraction: 0; rightFraction: 1; bottomFraction: 1 offset: self menuBarHeight negated; yourself); name: #PlotViewport; children: {}; yourself!
Item was changed: ----- Method: ThreadInspector>>selectProportionFrom:to: (in category 'plotting') ----- selectProportionFrom: lowPortion to: highPortion
+ |timeRange newStartTime newEndTime| - |timeRange| timeRange := self currentEndTime - self currentStartTime. + newStartTime := self currentStartTime + (timeRange * lowPortion) rounded. + newEndTime := self currentStartTime + (timeRange * highPortion) rounded. + "Push the current zoom level on the stack so that we can find it later in #zoomOut." + self zoomStack push: {self currentStartTime. self currentEndTime}. + self plotGraphFrom: newStartTime to: newEndTime.! - self plotGraphFrom: self currentStartTime + (timeRange * lowPortion) rounded - to: self currentStartTime + (timeRange * highPortion) rounded.!
Item was changed: ----- Method: ThreadInspector>>visualize (in category 'plotting') ----- visualize
self initializeGraph. self plotGraphFrom: self startTime to: self ownerLog last timestamp. graph openInWorld.!
Item was changed: + ----- Method: ThreadInspector>>windowMemberSpecsFor: (in category 'toolbuilder') ----- - ----- Method: ThreadInspector>>windowMemberSpecsFor: (in category 'as yet unclassified') ----- windowMemberSpecsFor: builder
^ { self plotSpec: builder. self menuBarSpec: builder. }!
Item was changed: ----- Method: ThreadInspector>>zoomOut (in category 'plotting') ----- zoomOut
+ |zoomEntry| + zoomEntry := self zoomStack isEmpty + ifTrue: [{self startTime. self ownerLog last timestamp}] + ifFalse: [self zoomStack pop]. + self plotGraphFrom: zoomEntry first to: zoomEntry second.! - self plotGraphFrom: startTime to: self ownerLog last timestamp.!
Item was added: + ----- Method: ThreadInspector>>zoomStack (in category 'accessing') ----- + zoomStack + + ^ zoomStack!
Item was added: + ----- Method: ThreadInspector>>zoomStack: (in category 'accessing') ----- + zoomStack: aStack + + zoomStack := aStack.!
Item was changed: ----- Method: ThreadInspectorPlotMorph>>moveYMidToZero (in category 'as yet unclassified') ----- moveYMidToZero "This is the most useful marker for thread inspection as 0 means 'disowned'." | zeroFraction | ymid contents: (yAxisFormatter value: 0).
self assert: (self minPoint y < 0 and: [0 < self maxPoint y]).
zeroFraction := self maxPoint y / (self maxPoint y - self minPoint y). ymid position: (self topLeft + + ((15 - ymid width max: 0) @ (self height - (ymid height*2) * zeroFraction) rounded) - + ((15 - ymid width max: 0) @ (self height - ymid height * zeroFraction) rounded) + (self borderWidth @ 0)).!
vm-dev@lists.squeakfoundation.org