[Vm-dev] microsecond timing for GC work

David T. Lewis lewis at mail.msen.com
Mon Jan 18 18:02:09 UTC 2010


This all looks reasonable to me.

The unix implementation is presumably straightforward. Windows is using
GetTickCount() for ioMSecs(), so very likely it would be sufficient to
use GetTickCount() * 1000 for ioMicroSeconds().

As a sanity check though - I'm not sure that any of the platforms can
actually measure a time resolution to accuracy greater than 1 msec.
You may not be getting any practical benefit from reporting time to a
precision greater than this.

Dave

On Sun, Jan 17, 2010 at 03:57:10PM -0800, John M McIntosh wrote:
>  
> The attached change set and sq.h enable microsecond timing for GC work. 
> Please review for consideration for VMMaker. 
> 
> I've added a named primitive
> 
> primitiveMicrosecondClock
> 	"This is a named (not numbered) primitive in the null module (ie the VM)"
> 	self export: true.
> 	self pop: 1 thenPush: (self positive64BitIntegerFor: (self ioMicroSeconds)).
> 
> 
> I used the 'sqLong' data type, but we don't seem to have a usqLong type to get unsigned long long  ? 
> Since in this case I'd like the 64bit value to be positive only value... 
> 
> Where on OS-X Cocoa VM V5 it is 
> 
> sqLong ioMicroSeconds(void)
> {
> 	//API Documented
> 	struct timeval now;
> 	sqLong theTimeIs;
> 	
> 	gettimeofday(&now, 0);
> 	if ((now.tv_usec-= startUpTime.tv_usec) < 0) {
> 		now.tv_usec+= 1000000;
> 		now.tv_sec-= 1;
> 	}
> 	now.tv_sec-= startUpTime.tv_sec;
> 	theTimeIs = now.tv_usec;
> 	theTimeIs = theTimeIs + now.tv_sec * 1000000;
> 	return theTimeIs;
> }
> 
> This follows the pattern for ioMicroMSecs which has it roots in the Unix code, which is: 
> 
> sqInt ioMSecs(void)
> {
>   struct timeval now;
>   gettimeofday(&now, 0);
>   if ((now.tv_usec-= startUpTime.tv_usec) < 0)
>     {
>       now.tv_usec+= 1000000;
>       now.tv_sec-= 1;
>     }
>   now.tv_sec-= startUpTime.tv_sec;
>   return lowResMSecs= (now.tv_usec / 1000 + now.tv_sec * 1000);
> }
> 
> 
> An interesting thing here btw is that the unix variation uses "startUpTime" which gets set to a clock time at VM startup time, so 
> the value zero is the start time of VM, versus a time from the squeak epoch time start value.  Also I use theTimeIs to ensure we don't have a 64bit overflow in the math
> ** Assuming the C compiler actually realizes the math has to be long long  for the now.tv_sec * 1000000  (interesting question perhaps)....  ***
> 
> 
> and then I  had to alter 
> 
> 	aCCodeGenerator var: #statGCTime type: #'sqLong'.
> 	aCCodeGenerator var: #statFullGCMSecs type: #'sqLong'.
> 	aCCodeGenerator var: #statIGCDeltaTime type: #'sqLong'.
> 	aCCodeGenerator var: #statIncrGCMSecs type: #'sqLong'.
> 
> and 
> 	startTime in fullGC and incrementalGC 
> 
> so that they are 64bit values. 
> 
> 
> 
> --
> ===========================================================================
> John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
> 



> 
> 
> 



More information about the Vm-dev mailing list