Squeak is doing a *lot* of gettimeofday()

Lex Spoon lex at cc.gatech.edu
Tue Feb 12 17:53:45 UTC 2002


John say:
> If you look at the source code sqXWindow.c you'll see some logic around
> USE_ITIMER which uses   sigaction(SIGALRM, &sa, 0); and 
> setitimer(ITIMER_REAL, &iv, 0); to trigger a sig alarm every 20 msecs 
> to update a low resolution ms clock. That clock as you can see gets 
> called a lot. Upwards of 40,000 times a second on a fast machine.
> 
> But turning ITIMER on means  all system calls must check for EINTR, 
> which I  don't think they do so there are side effects.


Spot on.  It would be wonderful if someone put in all the checks for
EINTR so that this could be enabled more often.  There's no reason for
this primitive to be so expensive.

If anyone goes after it, it would be nice to do it one
of these ways to avoid having the ugly while loop scattered
everywhere:

	1. Make a macro that repeats system calls as needed.

	2. Make a repeating version of each system call that does the
	   "while (result<0 && errno==EINTR)".  write_r() for write(),
	   readdir_r() for readdir(), etc.  Put these all in a C file,
	   and update all the callers.

	1+2.  Both, I suppose.  :)


If you want an excuse to get to know the Unix VM for some reason,
this is a great way to do it.  :)



Scott say:
> Although John's solution works, its not the ideal; it makes the checks a
> little cheaper, but does not remove them. This still leaves behind a
> noticable overhead. While, THIS:

It should make them a *LOT* cheaper: it's a variable read versus a system call.


-Lex



More information about the Squeak-dev mailing list