Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Time-HiRes CPAN distribution.

Report information
The Basics
Id:
5933
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
jdhedden [...] 1979.usna.com
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
1.56
Fixed in:
(no value)



This 'bug' was found tracking down a problem I had with interval timers getting off track in the Event module. (This occurred under the Cygwin environment on a Windows 98 machine.) PCs are terrible time keepers. It seems that under heavy load, the clock can continually loose time. On my laptop, I run an NTP client every 5 minutes to compensate for this. Doing so then causes problems with Time::HiRes. Whereas Perl's core time() function picks up on the NTP clock adjustments, Time::HiRes::time() does not. To see this, run the following test script. #!/usr/bin/perl use strict; use warnings; use Time::HiRes; while (1) { print("Core : ", scalar localtime(), "\n"); print("HiRes: ", scalar localtime(Time::HiRes::time), "\n\n"); sleep(10); } Then adjust your PC's clock. You'll see that the 'Core' time picks up the adjustment, but the HiRes time does not.
Yes, this is a side-effect of the implementation of Time::HiRes on Win32 - time adjustments made after the Perl script is started (or, rather, after the first time Time::HiRes::time() is called), are not reflected in the Time::HiRes::time(). Off-hand my Win32 informants do not promise any easy fixes since the high resolution of Time::HiRes::time() in Win32 is based on "performance counters" of Win32 which do not know anything about time adjustments like ntp.
I think Time::HiRes 1.59 should resolve the problem (as well as it is possible).
From: jdhedden@1979.usna.com
[JHI - Mon Apr 19 14:30:17 2004]:
Show quoted text
> I think Time::HiRes 1.59 should resolve the problem (as well as it is > possible).
I tested this change. It appears that the drift rate may have decreased, but the problem still persists.
This should have been fixed by 1.58 (1.59 is out by now), drift larger than 0.5 seconds should now be detected automatically by T::H and rectified.
From: Jerry D. Hedden
[JHI - Sat May 8 04:05:59 2004]:
Show quoted text
> This should have been fixed by 1.58 (1.59 is out by now), drift > larger than 0.5 seconds should now be detected automatically by > T::H and rectified.
It is not fixed. I have tested this twice in my system. In my most recent test, the clock actually started out 3 seconds behind. Over the course of 10 hours, it gained 20 seconds. My system uses Event.pm which, by default, uses Time::HiRes for its clock. When I configure Event.pm so that it uses core::Time, the clock tracks fine.
Show quoted text
> It is not fixed. I have tested this twice in my system. In my most > recent test, the clock actually started out 3 seconds behind. Over > the course of 10 hours, it gained 20 seconds. My system uses Event.pm > which, by default, uses Time::HiRes for its clock. When I configure > Event.pm so that it uses core::Time, the clock tracks fine.
Rats. I am unfortunately out of ideas what to do since I do not have the Win32-fu to fix this.
From: Jerry D. Hedden
Here is a sample program and results that show the problem: #!/usr/local/bin/perl use strict; use warnings; use Time::HiRes; $| = 1; while (1) { sleep(900 - (CORE::time() % 900)); printf("Core: %02d:%02d:%02d HiRes: %02d:%02d:%02d\n", (localtime(CORE::time()))[2,1,0], (localtime(Time::HiRes::time()))[2,1,0]); } # EOF Results: Core: 22:00:00 HiRes: 22:00:00 Core: 22:15:01 HiRes: 22:15:00 Core: 22:30:13 HiRes: 22:29:59 Core: 22:45:00 HiRes: 22:44:46 Core: 23:00:01 HiRes: 22:59:46 Core: 23:15:01 HiRes: 23:14:45 Core: 23:30:01 HiRes: 23:29:44 Core: 23:45:00 HiRes: 23:44:43 Core: 00:00:01 HiRes: 23:59:43 Core: 00:15:00 HiRes: 00:14:42 Core: 00:30:00 HiRes: 00:29:42 Core: 00:45:00 HiRes: 00:44:42 Core: 01:00:01 HiRes: 00:59:42 Core: 01:15:01 HiRes: 01:14:41 Core: 01:30:02 HiRes: 01:29:40 Core: 01:45:00 HiRes: 01:44:38 Core: 02:00:02 HiRes: 01:59:38 Core: 02:15:01 HiRes: 02:14:36 Core: 02:30:01 HiRes: 02:29:35 Core: 02:45:01 HiRes: 02:44:34 Core: 03:00:02 HiRes: 02:59:33 Core: 03:15:01 HiRes: 03:14:31 Core: 03:30:02 HiRes: 03:29:30 Core: 03:45:01 HiRes: 03:44:28 Core: 04:00:01 HiRes: 03:59:27 Core: 04:15:02 HiRes: 04:14:26 Core: 04:30:01 HiRes: 04:29:24 Core: 04:45:02 HiRes: 04:44:23 Core: 05:00:01 HiRes: 04:59:21 Core: 05:15:02 HiRes: 05:14:20 Hope it helps.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.