Delay and Linux
John M McIntosh
johnmci at smalltalkconsulting.com
Mon Jun 11 17:34:00 UTC 2007
Well in May of 2002 ([ENH] relinquishProcessorForMicroseconds:)
We used
| 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.
and Ian noted
> NetBSD ppc:
> a SortedCollection(950->20 19->19 19->21 3->18 3->22 2->30 1->25 1->8
> 1->10 1->14)
>
> Linux 386:
> a SortedCollection(294->1 213->2 146->3 100->4 84->5 55->6 33->7
> 33->8
> 11->10 9->11 8->9 6->13 5->12 1->14 1->17 1->18)
>
> Ian
on os-x 10.4.9 with a 3.8.17x VM I get
a SortedCollection(878->10 122->11)
Plus checking the clock gives
| bag time |
bag := Bag new.
time := Time millisecondClockValue.
1 to: 1000 do:[:i|
[Time millisecondClockValue = time] whileTrue.
bag add: (Time millisecondClockValue - time).
time := Time millisecondClockValue.
].
bag sortedCounts
a SortedCollection(1000->1)
However when you boot os-x and other BSD based unix systems it prints
standard timeslicing quantum is 10000 us
This is a clue, which means the operating system switches processes
as fine grained as 10 ms.
Old linux systems actually would switch on 100ms, those were called
non-real-time unix systems.
However in cross checking using a 3.2.8b9 VM (powerpc emulated on
macintel) I get
a SortedCollection(867->1 132->2 1->3)
However the code base used for 3.2.8b9 is different and I used a non-
portable delay semaphore which os-x gives good time accuracy to.
But at some point I migrated towards the unix
relinquishProcessorForMicroseconds code base because that tied into
aioSleep().
Talk to your unix support person about how best to solve this...
On Jun 11, 2007, at 6:54 AM, Gary Chambers wrote:
> Hi all. Does anybody know why, on the Linux VM (3.9.8), short Delays
> (<500ms) wait for significantly longer than under Windows (3.10.4)?
>
> As an example for the average time spent waiting when requesting a
> 10ms
> wait:
>
>
> ((1 to: 100) collect: [:i | Time millisecondsToRun: [(Delay
> forMilliseconds:
> 10) wait]]) sum / 100.0
>
> This yields (on my machine) 10.35 for Windows and 43.48 for Linux.
> For a 100ms wait: 100.5 (Windows) and 131.39 (Linux).
> For a 1000ms wait: 1000.36 (Windows) and 1013.16 (Linux).
>
> There seems to be a fixed overhead per call that is significantly
> larger
> under Linux.
>
> Any thoughts would be appreciated.
>
>
--
========================================================================
===
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
========================================================================
===
More information about the Squeak-dev
mailing list
|