[WIP] Make get-internal-real-time monotonic#46
[WIP] Make get-internal-real-time monotonic#46eugeneia wants to merge 5 commits intoClozure:masterfrom
Conversation
On Darwin it now correctly returns a value in ns, see https://developer.apple.com/library/content/qa/qa1398/_index.html On Windws it now correctly returns a monotinic value
level-1/l1-lisp-threads.lisp
Outdated
| (max 1000 (#_sysconf #$_SC_CLK_TCK))) | ||
|
|
||
| (defloadvar *ns-per-second* | ||
| 1000000000) |
There was a problem hiding this comment.
This looks like a job for defconstant.
level-1/l1-lisp-threads.lisp
Outdated
| 1000000000) | ||
|
|
||
| (defloadvar *ns-per-millisecond* | ||
| (floor *ns-per-second* 1000)) |
|
For the record, I believe the reason that we saved the initial seconds value from gettimeofday was so that operations on internal time unit values would likely be fixnum operations. It's definitely more correct to use If we use We might also have to generate new Windows headers so that the |
|
Note that only on Windows this |
|
I also thought about fixnums with regard to
I am temped to ignore the six days of fixnums on 32bit CCL because it’s an easily imaginable run time of a program. Since we are getting time in nanoseconds here anyways, the 36 year mark applies indirectly through |
*ns-per-second* → +ns-per-second+ *ns-per-millisecond* → +ns-per-millisecond+
See Also: #20
This work-in-progress PR moves
ccl:current-time-in-nanosecondsfrom lib/time to l1-lisp-threads, and uses it to implementget-internal-real-timeandccl::get-tick-count.The previous implementation of
get-internal-real-timeremembered the initial seconds value and subtracted it from values before returning them. I.e. the values returned byget-internal-real-timewould be close to zero after starting CCL. The new implementation does no such thing, the value returned is relative to system boot time.Additionally it changes
ccl:current-time-in-nanosecondstoCould anyone on Windows/Darwin test these changes? I remember Microsoft to provide virtual machine images for testing, but I doubt they include a C compiler? Anyway, this should print as shown below: