[Vm-dev] microsecond timing for GC work
John M McIntosh
johnmci at smalltalkconsulting.com
Sun Jan 17 23:57:10 UTC 2010
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
===========================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sq.h
Type: application/octet-stream
Size: 17405 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100117/9da0936a/sq-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JMMAddMicroSecondsForGCTiming.1.cs
Type: application/octet-stream
Size: 16406 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100117/9da0936a/JMMAddMicroSecondsForGCTiming.1-0001.obj
-------------- next part --------------
More information about the Vm-dev
mailing list