Threads or suggestion?

Andreas Raab Andreas.Raab at gmx.de
Thu Aug 8 21:05:32 UTC 2002


Stephen,

> I am interested in these things.  Also, I've been itching to make
> Comanche do it's socket serving using processes that are pre-empted.
> The only way I know that that can be achieved is to run a higher
> priority process that loops around a timer event (like a Delay). 
> That seems to me like it would probably be a good bit of overhead 
> if you were doing that say every 250 milliseconds. 

You must be kidding! The overhead for process switching is almost
unmeasurable (last time I counted it in the range of four message
sends). You can easily do that every 10 msecs without noticing anything.

Try this:

	delay := Delay forMilliseconds: 10.
	done := false.
	scheduler := [[done] whileFalse:[delay wait]] forkAt: Processor
userInterruptPriority.
	xx := 0 tinyBenchmarks.
	done := true.
	xx.

and measure this against a #tinyBenchmark without the "overhead". Here
are my results:

tinyBenchmarks raw (3 runs):
 '114285714 bytecodes/sec; 3422322 sends/sec'
 '115627822 bytecodes/sec; 3425013 sends/sec'
 '116575591 bytecodes/sec; 3419636 sends/sec'

tinyBenchmarks with scheduler overhead (3 runs):
 '116047144 bytecodes/sec; 3361587 sends/sec'
 '113174182 bytecodes/sec; 3403607 sends/sec'
 '111014744 bytecodes/sec; 3382466 sends/sec'


Cheers,
  - Andreas




More information about the Squeak-dev mailing list