Hi all,
I just made an interesting observation:
[1000 timesRepeat: [0.001 seconds wait]] timeToRun. "--> 2612"
I think the reason for this might be that Delay >> #schedule uses a critical section that is also accessed by the TimerEventLoop process with the highest priority in the system, so the synchronization overhead would be the bottleneck in this case.
Instead, if you need to produce many short delays anyway (for instance, to simulate a running process, just like me right new), you can use a busy-wait instead:
Duration >> busyWait
| proceedTime |
proceedTime := Time utcMicrosecondClock + self asMicroSeconds.
[Time utcMicrosecondClock >= proceedTime] whileFalse
<http://www.hpi.de/>
[1000 timesRepeat: [0.001 seconds busyWait]] timeToRun "--> 1000"
Much faster.
Could we need this in the Trunk, too?
Best,
Christoph
A new version of Chronology-Core was added to project The Inbox:
http://source.squeak.org/inbox/Chronology-Core-ct.67.mcz
==================== Summary ====================
Name: Chronology-Core-ct.67
Author: ct
Time: 2 July 2021, 6:11:19.127885 pm
UUID: 7a3d4136-ddb1-ea49-a035-d166391d3fb1
Ancestors: Chronology-Core-dtl.66
Adds Duration >> #busyWait and some explaining prose.
See http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-July/215928.html. Thank you for the feedback!
=============== Diff against Chronology-Core-dtl.66 ===============
Item was added:
+ ----- Method: Duration>>busyWait (in category 'squeak protocol') -----
+ busyWait
+ "Run an infinite loop until the receiver has elapsed. Performance-intensive!! Usually, you will want to use #wait instead which does not stress the interpreter but instead uses a delay, giving other processes the chance to run. However, scheduling a Delay comes with a synchronization overhead which denies its suitability for very short or precise delays. See http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-July/215928.html for further information."
+
+ "[3 seconds busyWait] timeToRun"
+
+ | proceedTime |
+ proceedTime := Time utcMicrosecondClock + self asMicroSeconds.
+ [Time utcMicrosecondClock >= proceedTime] whileFalse!
Item was changed:
----- Method: Duration>>wait (in category 'squeak protocol') -----
wait
+ "Convert this duration in a delay and wait once. Answer the created delay so that the client can wait on it again if needed. While this is the most CPU-friendly implementation, it comes with a small overhead for scheduling the delay as scheduling must be synchronized over all processes (see Delay >> #schedule). For very short, precise delays, consider using #busyWait instead."
- "Convert this duration in a delay and wait once. Answer the created delay so that the client can wait on it again if needed."
"[3 seconds wait] timeToRun"
^self asDelay wait!
Eliot Miranda uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-eem.1237.mcz
==================== Summary ====================
Name: System-eem.1237
Author: eem
Time: 2 July 2021, 6:13:21.540315 am
UUID: 30d3cf8e-708e-4830-86da-21d106f44ba8
Ancestors: System-eem.1236
Fix MessageTally class>>#tallySends:
=============== Diff against System-eem.1236 ===============
Item was changed:
----- Method: MessageTally class>>tallySendsTo:inBlock:showTree: (in category 'spying') -----
tallySendsTo: receiver inBlock: aBlock showTree: treeOption
"
MessageTally tallySends: [3.14159 printString]
"
"This method uses the simulator to count the number of calls on each method
invoked in evaluating aBlock. If receiver is not nil, then only sends
to that receiver are tallied.
Results are presented as leaves, sorted by frequency,
preceded, optionally, by the whole tree."
| prev tallies startTime totalTime |
startTime := Time millisecondClockValue.
tallies := MessageTally new class: aBlock receiver class method: aBlock method.
tallies reportOtherProcesses: true. "Do NOT filter nodes with nil process"
prev := aBlock.
+ thisContext
- thisContext sender
runSimulated: aBlock
contextAtEachStep: [ :current |
current == prev ifFalse: [ "call or return"
prev sender == nil ifFalse: [ "call only"
(receiver == nil or: [ current receiver == receiver ])
ifTrue: [ tallies tally: current by: 1 ] ].
prev := current ] ].
totalTime := Time millisecondClockValue - startTime // 1000.0.
(StringHolder new contents:
(String streamContents:
[:s |
s nextPutAll: 'This simulation took ' , (totalTime printShowingMaxDecimalPlaces: 2)
, ' seconds.'; cr.
treeOption
ifTrue: [ tallies fullPrintExactOn: s ]
ifFalse: [ tallies leavesPrintExactOn: s ] ]))
openLabel: 'Spy Results'!
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.1060.mcz
==================== Summary ====================
Name: Tools-eem.1060
Author: eem
Time: 1 July 2021, 2:40:56.604268 pm
UUID: 812128d2-6043-4a23-b5ad-307b59d7063a
Ancestors: Tools-eem.1059
Use a much more straight-0forward and accurate way to determine if the debugger is at an initial break in toggle break on entry. Also remember to test the result of the determination ;-)
=============== Diff against Tools-eem.1059 ===============
Item was changed:
----- Method: Debugger>>toggleBreakOnEntry (in category 'breakpoints') -----
toggleBreakOnEntry
"Override to rset to the new breakless method if stopped at a break point.
N.B. does not (yet) do the reverse."
+ | ctxt prevPC atInitialBreak newMethod |
- | ctxt prevPC bytecodeMessage atInitialBreak newMethod |
((ctxt := self selectedContext) isNil
or: [(prevPC := ctxt previousPc) isNil]) ifTrue:
[^super toggleBreakOnEntry].
+ atInitialBreak := ctxt selectorJustSentOrSelf == #break
+ and: [(ctxt method pcPreviousTo: ctxt previousPc) = ctxt method initialPC].
- bytecodeMessage := ctxt method abstractBytecodeMessageAt: ctxt previousPc.
- atInitialBreak := bytecodeMessage selector = #send:super:numArgs:
- and: [bytecodeMessage arguments = #(break false 0)].
super toggleBreakOnEntry.
+ newMethod := ctxt method methodReference compiledMethod.
+ (atInitialBreak
+ and: [newMethod isCompiledCode
+ and: [newMethod ~~ ctxt method]]) ifTrue:
- ((newMethod := ctxt method methodReference compiledMethod) notNil
- and: [newMethod ~~ ctxt method]) ifTrue:
[ctxt privRefreshWith: newMethod.
self resetContext: ctxt.
self debug]!
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.1059.mcz
==================== Summary ====================
Name: Tools-eem.1059
Author: eem
Time: 1 July 2021, 2:33:26.752346 pm
UUID: 5344c155-ba05-4999-b9de-58c6c31c2aa7
Ancestors: Tools-mt.1058
Have the Debugger reset the context to the new method when doing toggle bre4ak on entry when stopped at a break.
Hack MessageTrace to display Stores into foo when browsing assignments, rather than Senders of foo.
=============== Diff against Tools-mt.1058 ===============
Item was added:
+ ----- Method: Debugger>>toggleBreakOnEntry (in category 'breakpoints') -----
+ toggleBreakOnEntry
+ "Override to rset to the new breakless method if stopped at a break point.
+ N.B. does not (yet) do the reverse."
+ | ctxt prevPC bytecodeMessage atInitialBreak newMethod |
+ ((ctxt := self selectedContext) isNil
+ or: [(prevPC := ctxt previousPc) isNil]) ifTrue:
+ [^super toggleBreakOnEntry].
+
+ bytecodeMessage := ctxt method abstractBytecodeMessageAt: ctxt previousPc.
+ atInitialBreak := bytecodeMessage selector = #send:super:numArgs:
+ and: [bytecodeMessage arguments = #(break false 0)].
+ super toggleBreakOnEntry.
+ ((newMethod := ctxt method methodReference compiledMethod) notNil
+ and: [newMethod ~~ ctxt method]) ifTrue:
+ [ctxt privRefreshWith: newMethod.
+ self resetContext: ctxt.
+ self debug]!
Item was changed:
----- Method: MessageTrace>>windowLabelAt: (in category 'private accessing') -----
windowLabelAt: anInteger
"return a suitable window label when there is an actual list item selected; work out what it should be based upon the array of autoSelectStrings or the current selection"
^(autoSelectStrings at: anInteger)
+ ifNil:
+ ['Implementors of ',
- ifNil: [ 'Implementors of ',
(self class
parse: self selection
+ toClassAndSelector: [ :class :selector | selector ])]
+ ifNotNil:
+ [:str| (windowLabel endsWith: str)
+ ifTrue: [windowLabel]
+ ifFalse: ['Senders of ', str]]!
- toClassAndSelector: [ :class :selector | selector ])
- ]
- ifNotNil: [:str| 'Senders of ', str ]
- !
Hello all,
I just uploaded a new update of my experimental game engine for
real-time top-down parallaxed kinda roguelikes (what a mouthful).
It's there:
http://www.zogotounga.net/comp/squeak/rogue.htm
The newest developments in tactical gameplay and the combat system are
exemplified in a minigame of sorts:
RogueDemo testFightingArena
(see details in the iamge itself)
Stef