[squeak-dev] Re: [ANN] A new scheduler + VM changes alpha-release

Andreas Raab andreas.raab at gmx.de
Thu Apr 30 18:04:23 UTC 2009


A better benchmark is attached. It allows adjusting the number of 
processes and the total time the benchmark should run and answers the 
number of process switches per second. This is our "standard" process 
switch benchmark. Run it like here:

100 "processes" benchSwitch: 5. "seconds"

This will switch between 100 processes for 5 seconds.

Cheers,
   - Andreas

Andreas Raab wrote:
> Igor Stasenko wrote:
>> A quick comparion for Delays:
>>
>>        delay := Delay forMilliseconds: 1.
>>        bag := Bag new.
>>        1000 timesRepeat:[bag add: [delay wait] timeToRun].
>>        bag sortedCounts
>>
>> on my 4-core box it yields:
>>
>> - with AdvancedProcessorScheduler install
>>   a SortedCollection(951->2 49->1)
>>
>> - with Processor fallbackToOldScheduler
>>  a SortedCollection(953->2 47->1)
>>
>> - with old VM
>>   a SortedCollection(952->2 47->1 1->3)
>>
>> not much overhead huh? :)
> 
> That's not exactly the kind of benchmark I was looking for (if your 
> process scheduler takes milliseconds to do a switch I think we're not 
> even close to the ballpark ;-) More interesting for comparison is this 
> (requires closures):
> 
>   semas := Array new: 10000.
>   plist := Array new: 10000.
>   1 to: semas size do:[:i| semas at: i put: Semaphore new].
>   1 to: plist size-1 do:[:i| plist at: i put: [(semas at: i) wait. 
> (semas at:i+1) signal] fork].
>   [semas first signal. semas last wait] timeToRun.
> 
> Cheers,
>   - Andreas
> 
> 

-------------- next part --------------
'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 30 April 2009 at 11:00:16 am'!

!Integer methodsFor: 'benchmarks' stamp: 'eem 10/6/2008 11:32'!
benchSwitch
	"Run a benchmark computing the number of process switches per second.
	The reciever identifies the total number of processes to be used in the benchmark."
	"10 benchSwitch"
	^self benchSwitch: 1! !

!Integer methodsFor: 'benchmarks' stamp: 'ar 8/25/2008 16:46'!
benchSwitchCount: assoc wait: sema1 signal: sema2
	| p |
	p := [
		[true] whileTrue:[
			sema1 wait.
			assoc value: assoc value+1.
			sema2 signal.
		].
	] forkAt: Processor activePriority+1.
	p priority: Processor activePriority-1.
	^p! !

!Integer methodsFor: 'benchmarks' stamp: 'eem 10/6/2008 11:31'!
benchSwitch: seconds
	"Run a benchmark computing the number of process switches per second.
	The reciever identifies the total number of processes to be used in the benchmark.
	The argument is the length of time in seconds to run the test for."
	"10 benchSwitch"
	| semaphores processes count |
	count := Association key: #counter value: 0.
	semaphores := (1 to: self) collect:[:i| Semaphore new].
	processes := Array new: self.
	[
		1 to: processes size do:[:i| | p waitSema signalSema |
			waitSema := semaphores at: i.
			signalSema := semaphores atWrap: i+1.
			p := self benchSwitchCount: count wait: waitSema signal: signalSema.
			processes at: i put: p.
		].
		semaphores first signal.
		(Delay forSeconds: seconds) wait.
	] ensure:[
		processes do:[:p| p ifNotNil:[p terminate]].
	].
	^(count value // seconds) asStringWithCommas, ' switches/sec'! !



More information about the Squeak-dev mailing list