Random header image... Refresh for more!

Temporal Mechanics: Changing the Speed of Time

Until last week, I never really thought about my computer’s system clock.  I simply thought that it hummed along at a constant, smooth rate, always heading toward the future.  I figured that once a week, it would call a time server tethered to atomic clock somewhere and make sure that it’s in sync.  If not, it would immediately correct the time and go about its business for another week.

Turns out, I was wrong.  The way Windows handles time, particularly when a member of a domain is a tad more complicated.  And, as it turns out, you generally want it that way.

Think about the implications of the method I described above.  If your system clock is bad, that means that in the span of a week, you can get ten or fifteen minutes off of real time.  Then, in one big jump, your clock gets corrected, jumping your system ten minutes into the future, or forcing it to re-live the past ten minutes over again.  On your home system, that’s probably not a huge deal.  Timestamps on all the movies you’re downloading might be off by a bit, big deal.  But in the business world, that would be bad.  Your Outlook reminders would fire off at different times for different people, e-mails and instant messages would have odd timestamps, and the Kerberos system used for authentication would randomly block people for being outside of an acceptable time range.

In short:  Mayhem.

So, when you’re joined to a domain, Windows typically gets a bit stricter over how it handles time synchronization.  It does this to keep all machines in line.  That’s why you hear the meeting reminder bell rising from fifteen machines in your cubicle farm at nearly the same moment.  The Windows Time Service is keeping everyone synchronized.

Now, there’s a good chance that you already knew that, if you’ve been around networks long enough.  But, there’s an equally good chance that you don’t know how the Windows Time Service is keeping everyone synchronized.  I had always assumed that the Time Service was keeping everyone in sync by resetting everyone’s clocks to the correct time every hour or so, and that no one ever noticed because your internal system clock kept good time.  In other words, at 1:03:27 PM, your computer would be told that it was 1:03:27 PM, so it would set the time, and it would still be 1:03:27 PM.

That ain’t what it does.

In fact, your computer’s clock doesn’t really matter to Windows.  Windows really only pays attention to it when it first starts up.  Beyond that, the magic of the Windows Time Service keeps things in line.

The Windows Time Service doesn’t really like setting your time at all, once it’s running.  It will do so, if your clock gets too far away from the time authority, but in general, it won’t set your time.  So, how does it keep a flock of computers running in perfect Outlook harmony?


It changes the speed of time.

I’ll get into that, but first, let’s change your perception of time.  Time, at least from the perspective of a Windows machine, is not linear.  Instead, it’s a step function.  The exact values vary from system to system, but these are the basics:  Every 15 ms or so, the clock bumps its time value by 15 ms or so.  If you’ve ever done a Console.WriteLine(DateTime.Now.Ticks); inside a tight while loop ((Go ahead, try it.)), you’ve seen the effects of this.  The value will remain constant for many iterations, then leap up, then stay at the new level for a while, then jump.  Similarly, if you’ve ever mistakenly tried to use DateTime for recording performance numbers, you’ve run into something similar.  All of your perf times are reporting 0ms, 15ms, or 31ms.  It’s always one of those three.  Never 7, never 12, never 24.  That’s because the resolution of the time is 15ms.

In other words, time looks like this:

The smooth black line is “real time” and the stepping red line is your computer’s time.

All is well in graph-land.  The time your computer reads might move in discrete chunks, but it’s always centered around real time, so you’re never more than 7.5 ms off of reality.

But what happens if the clock in your computer is bad?  The quartz crystal has gone on a vacation to a big sphinx with the Jackdaws or the cesium atom is vibrating 9192631771 times a second.  Your computer will think that it’s adding 15ms, but it’s actually adding slightly more or less time.  Let’s take a 5% error rate.  For every 15 ms of real time, your computer adds 15.75 ms to its clock.  That looks like this:

You’ve gone off the chart.  The error accumulates and time starts drifting.  At the end of this sample graph, which represents only 135 ms, your clock has already drifted so far that it now will never be correct.  At this rate, after ten minutes, you’ll be 30 seconds off.

Obviously, that’s not good.  What the system could do is reset your clock every ten minutes to the correct time.  Except that you’d notice a jump like that and you’d get annoyed.  Granted, 5% is a large error for a system clock, but the premise is the same regardless of the size of the error.  Small errors add up to big problems.  Even if you only drifted a second every ten minutes, that one second skip would cause trouble to enough people that it would be a major issue.  So, like I said, the Windows Time Service will change the speed of time to correct the clock.

It’s a bit like putting your finger on the second hand of a clock.  You can push it forward gently and the clock will move ahead, or you can resist the motion and the clock will fall behind.  That 15ms that the system adds to the clock is just a number.  On my machine, that number is 156250. ((So, I lied.  It’s not 15ms, it’s 15.6ms, but I’m not typing 15.6ms all the time.))  That’s the number of 100ns units of time that will get added to the clock every time it ticks.  ((100 nanoseconds is the base unit of time in the Windows world.  Windows File Time is given in the number of 100ns ticks since January 1st, 1601.  Why that date, I’m not sure, but I think it has something to do with the Illuminati and a Star Trek fan who wasn’t good at remembering numbers exactly.  There are 10000 of these in 1ms, and 10000000 of them in a second.))  But if your clock is too far ahead, all the system has to do is add a smaller number (Say, 150000) for a period of time, causing your computer’s clock to slow down, and letting reality catch up.

Back to the graph, this time with a 50% error for illustration purposes.

It’s adding 22.5ms for every 15ms of real time.  Very quickly, your clock is going off the rails.  Let’s change the speed of time and fix this problem.

The Windows Time Service saw the fact that the time was way off and changed the speed of time, slowing down the clock to two-thirds of its normal speed.  It started adding only 10ms of computer time every 15ms of real time.  This solved the problem very quickly, but has the unfortunate side effect of leaving your computer’s clock running too slow.  Now, instead of zooming ahead, it’s going to be falling further and further behind reality.  The solution, of course, is to speed time back up.

Now, the corrections don’t happen on this scale.  This is a huge simplification of the bizarre reality you’ll uncover if you ever watch the Windows Time Service work its magic.  Usually you’ll see something like a drift of 20ms over 10 minutes, then over the next ten minutes, the time service will slow the clock to lose those extra 20ms.  All day long, you’ll see your system drift in and out of phase with reality, but it should never get that far out of tune, and you’ll never notice what it does just by watching the clock.

Unless, of course, you deliberately set your clock ahead or behind…

You have to be careful, because the time service has a couple of cutoff thresholds where it will force a corrective time jump in order to fix the problem.  However, if you stay within those thresholds, you can watch w32time do some pretty awesome things.  Like make your system time gain seven minutes over the course of five real minutes, or make every second last two seconds.


Not that I’m suggesting you try this or anything, but while you’re at work tomorrow (On a computer that’s on a domain and synching regularly with an authoritative time source), get some popcorn, set your clock ahead or behind about 3.5 minutes, and compare your computer’s clock (You have to watch the view with the second hand) to some external time source, like your watch or cell phone.  When I’ve done this, it’ll start slowly.  The time will remain where it is for a while, then all of a sudden, time will accelerate (or decelerate) drastically for a period of a few minutes, then it will level off.  Within about half an hour, that 3.5 minute gap will be pretty much closed, and it never had to skip or repeat a second.

Of course, the specifics change with different machines, different Windows versions, and different network time configurations.  You may have to fiddle and twizzle with knobs and dials to see any noticeable result.  Fortunately, there’s Registry Settings located under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w32time that give you lots of knobs and dials to fiddle and twizzle.  You don’t necessarily want to mess with any of them, and I’d strongly recommend finding a reference to what they do before you set out on a time bending adventure using them.  I’d also strongly recommend exporting a backup copy of that reg key before you go mucking about, otherwise be prepared to be late for everything for the rest of your life.

Oh, and did I mention that you can change the speed of time yourself?  That makes this so much more fun, especially if it’s not your computer that you’re changing the speed of time on.  I’ll show you how to do that next time.

(If there is a next time…  I think I may have triggered a paradox and my hand seems to be disappearing now…)


1 Time Is Relative, Anyway — This Title Intentionally Left Blank { 03.03.11 at 23:05:28 [337] }

[…] year, during a brief foray into temporal mechanics, I learned all about how Windows deals with time and time synchronization.  One of the things I […]

2 Electric Curiosities: The Situation Is Under Control — This Title Intentionally Left Blank { 04.02.11 at 23:16:30 [303] }

[…] never end up in the search queries section of my stats.  You know what does?  “temporal mechanics“, which is completely unrelated to video game cartridges.  You know what else?  “sega […]

Leave a Comment