# A clock made of branches

DevFeed: [A clock made of branches](<https://devfeed.tech/articles/a-clock-made-of-branches-112306.md>)

Original publisher: [Read original article](<https://fzakaria.com/2026/11/01/a-clock-made-of-branches>)

Published: 2026-11-01T17:00:00Z

Content type: article

Language: en

Sources: [Farid Zakaria's Blog](<https://devfeed.tech/sources/farid-zakaria-s-blog.md>)

Topics: [virtual machines](<https://devfeed.tech/topics/virtual-machines.md>), [Emulator](<https://devfeed.tech/topics/emulator.md>), [scheduling](<https://devfeed.tech/topics/scheduling.md>)

Tags: [branch](<https://devfeed.tech/tags/branch.md>), [clock](<https://devfeed.tech/tags/clock.md>), [conditional](<https://devfeed.tech/tags/conditional.md>), [counter](<https://devfeed.tech/tags/counter.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [time](<https://devfeed.tech/tags/time.md>), [vm](<https://devfeed.tech/tags/vm.md>)

## AI overview

Rewind uses two guest-clock modes for deterministic replay. Exit time advances 5 microseconds whenever the guest exits, treating all work between exits as instantaneous; this can make timeouts impossible to reproduce and skew races. Counter time advances 1 nanosecond per retired conditional branch to account for guest work. In a billion-iteration loop, the conditional-branch count stayed at one billion across runs, while total instruction counts varied with interrupts and page faults because the counter also sees kernel activity. The author presents branch count as a repeatable, reasonably realistic proxy for time, while noting that AMD Zen can slightly overcount branches by default due to SpecLockMap; Rewind and rr address this by setting a PMU MSR bit.

## Source excerpt

What is time inside a machine you want to replay? 🧘 When building Rewind, a deterministic VM, you come face-to-face with the idea of how to represent time very quickly. You need a way to measure time inside the guest so that on subsequent replays, the guest sees the same time and makes the same decisions. Time is the ultimate variable.