<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww" -->

---
title: Why CPU Time ≠ Wall Clock Time! - Computerphile | daily.dev
description: An explanation of how computers track time internally, from early home computers counting interrupts to modern CPUs using the RDTSC instruction to read a time...
canonical: https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why CPU Time ≠ Wall Clock Time! - Computerphile | daily.dev
og:description: An explanation of how computers track time internally, from early home computers counting interrupts to modern CPUs using the RDTSC instruction to read a time...
og:url: https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww
og:image: https://api.daily.dev/og/posts/TNp7TuSWw.png
og:image:alt: Why CPU Time ≠ Wall Clock Time! - Computerphile
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why CPU Time ≠ Wall Clock Time! - Computerphile

**[Computerphile](https://daily.dev/sources/computerphile)** · 19 min read · 0 upvotes · 0 comments

## Summary

An explanation of how computers track time internally, from early home computers counting interrupts to modern CPUs using the RDTSC instruction to read a time stamp counter. Covers how operating systems convert raw CPU cycle counts into nanosecond wall-clock time using integer multiply-and-shift tricks, how NTP corrects clock drift, the vDSO trick Linux uses to avoid expensive syscalls, and why out-of-order execution and instruction reordering make precise cycle-level benchmarking tricky, requiring serializing instructions like RDTSCP and CPUID.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=xs5iOwkX9fU>

## Questions this post answers

### What does the x86 RDTSC instruction actually measure?

RDTSC (read timestamp counter) reads a hardware counter that increments at a fixed base clock rate, independent of CPU frequency scaling or core sleep states, giving a stable count of elapsed cycles since some reference point. Operating systems convert this count into nanoseconds using a boot-time offset plus an integer multiply-and-shift factor approximating the counter's frequency, avoiding costly floating-point division.

_Engineers optimizing low-level timing code can follow deep dives like this on daily.dev._

### Why does RDTSC give inconsistent cycle counts when used for benchmarking?

Because RDTSC does not wait for prior instructions to finish, out-of-order CPUs can execute it early, so a single measurement might show ~33 cycles while millions run back-to-back at ~300 cycles due to instruction scheduling effects. The fix is using RDTSCP, which forces earlier instructions to complete first, plus serializing instructions like CPUID on both sides to prevent code from leaking into the benchmarked region.

_daily.dev surfaces practical notes like this for developers chasing accurate microbenchmarks._

### How does Linux let user-space programs read the time without an expensive system call?

Linux maps four values (time, offset, factor, and shift) into a read-only memory region accessible from user space via the vDSO mechanism, letting programs compute wall-clock time directly from the RDTSC counter without a privileged system call. This user-space calculation takes roughly 35 nanoseconds, far cheaper than the overhead of a full kernel transition.

_Developers tuning latency-sensitive code can track kernel timing tricks like this via daily.dev._

## Similar posts on daily.dev

- [The fastest Linux timestamps · hmpc](https://daily.dev/posts/the-fastest-linux-timestamps-hmpc-evqoy4ob7) · Lobsters · 0 upvotes · 0 comments
- [A clock made of branches](https://daily.dev/posts/a-clock-made-of-branches-bxrqnrnxg) · Farid Zakaria’s Blog · 0 upvotes · 0 comments

---

Tags: [#hardware](https://daily.dev/tags/hardware), [#linux](https://daily.dev/tags/linux), [#performance](https://daily.dev/tags/performance)

[View this post on daily.dev](https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why CPU Time ≠ Wall Clock Time! - Computerphile","url":"https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww"},"datePublished":"2026-08-27T13:20:38.291Z","dateModified":"2026-10-15T02:23:48.101Z","description":"An explanation of how computers track time internally, from early home computers counting interrupts to modern CPUs using the RDTSC instruction to read a time...","image":"https://i.ytimg.com/vi/xs5iOwkX9fU/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/xs5iOwkX9fU/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Computerphile","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Computerphile","logo":"https://media.daily.dev/image/upload/s--hZFFIKfd--/f_auto/v1712315606/logos/computerphile","url":"https://daily.dev/sources/computerphile"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"hardware,linux,performance","timeRequired":"PT19M","video":{"@type":"VideoObject","name":"Why CPU Time ≠ Wall Clock Time! - Computerphile","description":"An explanation of how computers track time internally, from early home computers counting interrupts to modern CPUs using the RDTSC instruction to read a time...","thumbnailUrl":"https://i.ytimg.com/vi/xs5iOwkX9fU/sddefault.jpg","uploadDate":"2026-08-27T13:20:38.291Z","duration":"PT19M","url":"https://api.daily.dev/r/TNp7TuSWw","embedUrl":"https://www.youtube.com/embed/xs5iOwkX9fU"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Computerphile","item":"https://daily.dev/sources/computerphile"},{"@type":"ListItem","position":3,"name":"Why CPU Time ≠ Wall Clock Time! - Computerphile"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/why-cpu-time-wall-clock-time---computerphile-tnp7tusww#faq","mainEntity":[{"@type":"Question","name":"What does the x86 RDTSC instruction actually measure?","acceptedAnswer":{"@type":"Answer","text":"RDTSC (read timestamp counter) reads a hardware counter that increments at a fixed base clock rate, independent of CPU frequency scaling or core sleep states, giving a stable count of elapsed cycles since some reference point. Operating systems convert this count into nanoseconds using a boot-time offset plus an integer multiply-and-shift factor approximating the counter's frequency, avoiding costly floating-point division. Engineers optimizing low-level timing code can follow deep dives like this on daily.dev."}},{"@type":"Question","name":"Why does RDTSC give inconsistent cycle counts when used for benchmarking?","acceptedAnswer":{"@type":"Answer","text":"Because RDTSC does not wait for prior instructions to finish, out-of-order CPUs can execute it early, so a single measurement might show ~33 cycles while millions run back-to-back at ~300 cycles due to instruction scheduling effects. The fix is using RDTSCP, which forces earlier instructions to complete first, plus serializing instructions like CPUID on both sides to prevent code from leaking into the benchmarked region. daily.dev surfaces practical notes like this for developers chasing accurate microbenchmarks."}},{"@type":"Question","name":"How does Linux let user-space programs read the time without an expensive system call?","acceptedAnswer":{"@type":"Answer","text":"Linux maps four values (time, offset, factor, and shift) into a read-only memory region accessible from user space via the vDSO mechanism, letting programs compute wall-clock time directly from the RDTSC counter without a privileged system call. This user-space calculation takes roughly 35 nanoseconds, far cheaper than the overhead of a full kernel transition. Developers tuning latency-sensitive code can track kernel timing tricks like this via daily.dev."}}]}
```

