[ENH] relinquishProcessorForMicroseconds:

John M McIntosh johnmci at smalltalkconsulting.com
Tue May 7 00:23:18 UTC 2002


Ian mention I was fiddling with relinquishProcessorForMicroseconds 
over the weekend, among fiddling with socket code and intel 
assembler....

So another test and input run needed from you fine windows and unix folks.
Apply this changeset to a test image you can or could throw away later...

Now take this code

|bag  time delay |
delay _ Delay forMilliseconds: 1.
bag _ Bag new.
1 to: 1000 do: [:i |
	time _ Time millisecondClockValue.
	delay wait.
	bag add: (Time millisecondClockValue - time).
].
bag sortedCounts.

run on favorite machine.

Say an image with a Squeak3.0.21MTCarbon macintosh VM (kinda old heh?)

a SortedCollection(322->17 244->33 215->16 95->34 24->23 24->44 
23->18 18->6 17->28 3->24 3->43 2->19 2->27 2->31 1->1 1->7 1->14 
1->15 1->32 1->35)

Boo hiss. the accuracy of Delay is 16ms Not what you expect!

Now take attached change set and try with same VM and image

Much better.

a SortedCollection(505->4 267->5 35->3 26->22 24->21 23->17 21->1 
19->6 17->2 15->18 11->23 8->8 8->20 4->7 3->24 2->9 2->51 2->19 
2->16 1->53 1->12 1->10 1->64 1->26 1->27)

(Historical VM logic implies looking every 5ms for interrupts, thus a 
cluster at 4 or 5).
(But I understand the Windows VM now just looks every 1 ms).
(New mac VM's and perhaps soon Unix VM will look every 3ms (down from 5ms)).

Now for Unix. Need some unix and some windows folks to test....

On unix currently the example code cheerfully gives

824->20 84->19 32->40 19->10 16->1

Boo hiss.

with the change set I get
a SortedCollection(341->1 223->2 120->3 73->4 50->5 29->6 22->7 
20->16 19->17 18->18 12->8 12->15 10->14 8->10 8->12 8->13 7->19 
6->11 3->20 2->9 2->21 2->23 1->24 1->25 1->26 1->27 1->30)

So the question is what do other people observe?
For unix folks (os-x too) I'd really also like to get observations 
about CPU usage when idle etc.

Note the 3.2.6 and onwards series of mac vm fiddle with the sleep 
value in the VM. However Ian said it's the responsibility of the 
smalltalk code to calculate a proper sleep period. So running this on 
a 3.2.7b4 Mac VM gives
a SortedCollection(533->2 278->3 46->23 31->24 24->22 21->1 15->4 
11->21 8->5 6->25 4->26 3->27 2->6 2->14 2->18 2->28 2->35 2->42 
2->43 1->12 1->15 1->20 1->29 1->41 1->47)

Note The change set clamps the sleep period from 2 milliseconds to 
1000 milliseconds. Under Unix we found that sleeping 1 millisecond 
really means a bunch. So that is why the clamp is at 2 versus 1.
Ian's current sleep logic returns if time is zero. But other 
implementations might not, but this is not an issue when clamping at 
2.


So go away and try.
-- 
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================
-------------- next part --------------
Skipped content of type multipart/appledouble


More information about the Squeak-dev mailing list