“The algorithm took 2400 clock cycles.” Let’s assume the author arrived at this number by subtracting the two RDTSC results. It is not yet known what exactly he measured; the label already promises too much. The number refers to the increment of the Time Stamp Counter, TSC. On a processor with invariant TSC, this counter serves as a steady time base, although the core execution frequency may vary. Calling these counts the clock cycles of the executing core silently changes the unit. The error appears in the label before a dispute about the speed of the algorithm begins.
The word “cycle” feels reassuringly concrete. It suggests a single beat of the processor: another increment of machine activity. But the hardware counter gets its meaning from its own incrementing rule, not from the CPU’s generic name. The device is capable of having multiple time bases, event counters, and execution time tracking. Representing both as integers does not transform these quantities into one. It is especially tempting to mix them when the instruction to read the timestamp is very short and the result looks more convincing than ordinary seconds.
Linux documentation on time in KVM on x86 shows why the history of TSC is not reduced to one phrase. Older processors could change the speed of the counter along with the power mode or stop it in some states. Constancy of speed and continuation of counting during idle time are separate properties reflected, in particular, by the constant_tsc and nonstop_tsc characteristics. Invariant TSC eliminates important dependencies on power modes, but the word itself is not a universal proof of the consistency of timestamps across arbitrary sockets and virtual machines.
Consider a fictitious example with a known TSC frequency of 2.4 GHz. A difference of 2400 ticks corresponds to one microsecond: the number is divided by 2.4 billion ticks per second. If the core was running at 4.8 GHz all this time, about 4800 of its clock cycles could have passed during the interval. At 1.2 GHz there would be about 1200. This is a hypothetical arithmetic for constant frequencies, not a measurement of a specific model. It is needed so that the same 2400 no longer automatically means the same number of core clock cycles.
Even the second number does not tell you how many instructions were executed. Some instructions may overlap, others may wait for data, and individual operations may turn into internal work. The microsecond does not disappear while waiting for memory. The time counter continues to move, although the useful result is almost no closer. Therefore, moving from TSC to a statement about "amount of CPU work" requires another unjustified step. Changing the label cannot turn a timestamp into a count of instructions, busy execution units, or useful operations.
The frequency in the denominator
In the example formula, it is the TSC frequency that is important. Substituting the current core frequency from the monitoring utility would be a new mistake: it answers a different question. In addition, the monitoring reading usually refers to its own interval and its own averaging technique. Even if on some platform both frequencies coincide numerically in the same mode, this coincidence does not establish a connection for the future. The procedure for determining the time base must be consistent with the architecture and conditions of its provision by the operating system.
The operating system handles this problem more broadly than an isolated RDTSC call. On Linux, the clock_gettime interface allows you to request a specific clock with defined semantics. CLOCK_MONOTONIC is designed for monotonic time, and the process or thread’s CPU clock accounts for its execution. Time waiting to be scheduled can increase the elapsed monotonic time without increasing the processor time at all. The choice of clock already makes a statement about what the author intends to call duration.
The name MONOTONIC also does not replace reading the document. It describes a time scale without backward jumps; it does not provide an absolute UTC date or promise to count every system suspension. Linux distinguishes between, for example, CLOCK_MONOTONIC and CLOCK_BOOTTIME to account for system suspension. Resolution, timestamp retrieval overhead, and accuracy are different characteristics. It’s easy to produce a lot of decimal places; ensuring that they describe the right event is more difficult. A long number does not prove either a successful choice of clock or high accuracy of the experiment.
On Windows, Microsoft’s timestamp guidelines recommend QueryPerformanceCounter for measuring short intervals on a single system. The OS selects the appropriate hardware base and provides the QPC frequency through its own interface. Reading TSC directly removes some of this portability from the program. In this case, the QPC frequency cannot be considered the current core frequency or equated to the raw TSC frequency without checking. The interface promises a timeline, not a processor specification.

A timestamp must match the event
Let’s assume the unit is finally chosen correctly. The question remains which events bounded the count. An out-of-order processor is not required to turn the visible sequence of instructions into a simple time ruler. RDTSC is not a fully serializing instruction. Without suitable constraints, a read may end up positioned differently relative to the surrounding work than the original author intended. The frequency in the denominator will not correct incorrectly set boundaries: it will only carefully convert the incorrect interval into seconds.
The compiler also has freedom. A fragment whose result is not used anywhere may disappear; a calculation may be moved across measurement points. The hardware barrier and constraints on compiler reordering solve different problems. Therefore, the magical insertion of one instruction does not turn arbitrary source text into a ready-made microbenchmark. Before explaining ten counts as an advantage of the algorithm, one needs to know what is left in the machine code and what boundaries are actually provided for the desired operations.
Microsoft’s description of __rdtscp specifically emphasizes the partial ordering of this instruction: it waits for preceding instructions to execute and preceding loads to become globally visible, but is not a full serialization. From this it is impossible to derive a universal ready-made recipe for all memory stores and all subsequent commands. The choice of restrictions depends on whether you need to wait for local computation, retrieval of loaded data, or global visibility of stores. These are different definitions of the end of work. You cannot first select a convenient short sequence and then assign the broadest meaning to it.
An interrupt or preemption adds another kind of time. Another thread, handler, or hypervisor could be executing between the marks. If the scale continued, this pause is included in the difference. The result remains meaningful: it can still describe the latency of the observed operation. But it is no longer possible to declare the entire difference as the time when the core executed only the code under study. Inconveniently large values should also be excluded using an explicit method, otherwise the measurement of user waiting time will imperceptibly select the best conditions.
Moving a thread between cores requires a consistent scale. On supported modern systems, the OS can take into account many hardware features, but direct register reading shifts the verification of prerequisites to the program. RDTSCP also returns TSC_AUX, the meaning of which is specified by the OS. This supplies useful additional evidence rather than a universally standardized physical core number for any environment. The same auxiliary value does not certify the absence of all interventions, and the difference requires system-specific interpretation.
Virtualization makes this clause especially relevant. The hypervisor is capable of providing TSC to the guest with offset and scale adjustments. Guest migration, platform features, and paravirtual clock support are included in the measurement conditions. The guest’s 2400 ticks do not establish the frequency of the host physical core just because the instruction is named the same. For a guest program, a scale can be a great timer, but at the same time a bad way to guess the hardware organization of the machine outside its interface.
Sometimes the author really needs core events. Then performance counters with their own definitions are appropriate. perf_event_open distinguishes between hardware events, including cycles and reference cycles, and also allows you to limit the scope of accounting. The value depends on PMU support, filters and whether the counter was actually running for the entire required time. Multiplexing requires consideration of availability times. You can transfer this value to the column next to TSC, but you cannot label both columns with one unit without explanation.
This is where a useful editorial habit comes into play: the verb must match the observation. "Passed" refers to a time interval. “Executed” requires a defined scope of CPU accounting. “Completed instructions” – the corresponding event, and the instruction itself is not yet identical to user work. If three different experiments are returned to three precise sentences, the processor no longer seems contradictory. It can spend less real time, undergo more core cycles at a higher frequency, and complete the same number of instructions.
Comparisons between different CPUs are especially sensitive to such vocabulary. Raw TSC differences cannot be sorted as general competition points without accounting for their time bases. And after conversion to nanoseconds, the same task with the same defined ending is required. A faster timer does not make the job faster. A smaller counter value also does not guarantee benefits if it has a different unit. Here, the exact label is not a table decoration: it determines whether the table allows meaningful comparison at all.
A short interval also has a price for observation itself. A couple of readings and the necessary restrictions add work comparable to a small fragment under study. Subtracting one pre-measured "timer cost" does not have to eliminate it perfectly: adjacent instructions, dependencies, and machine state change the interaction. A series of repetitions within an interval may reduce the relative contribution of the marks, but creates a different experiment. Repetitions can take advantage of an already warmed-up cache and branch prediction. The resulting average then applies to the repeated operation rather than automatically to the first isolated operation.
Another hidden substitution occurs when dividing the total time by the number of elements. This is the acceptable average cost of processing in a given work organization. But it does not establish a dependency delay between two successive operations. Multiple independent calculations can be executed simultaneously, so throughput and latency vary even with the same machine code. TSC does not choose for the researcher what characteristic it will call “instruction speed.” That decision comes earlier, when constructing the load and choosing the moment when the desired result is considered available.
Finally, time on one machine cannot be mechanically used as a common clock for communication between machines. Two local monotonic counters can have different origins and slightly different rates. To establish the network delay of a one-way message, additional assumptions about synchronization and its error are needed; the difference between two raw registers does not create these prerequisites. The round-trip interval on one local timer has a different observation geometry. This is another reason to label not only the unit, but also the events between which the difference appeared.
Therefore, the hypothetical result at the beginning should be relabeled: “2400 TSC counts passed between the established boundaries; at a known frequency of 2.4 GHz, this is one microsecond.” The conditions of the readings, the environment, and possible interruptions still need to be specified. The number has not changed, but no longer promises the number of clock cycles of the execution core. Sources verified October 26, 2026. Our frequencies and values were an analytical example, and the editors did not carry out hardware measurements. A good unit preserves the usefulness of a number precisely by limiting its meaning.



