Different Latency Numbers Everyone Should Know
You may have heard the word latency when you were checking your PC or laptop configurations. If you have given it a proper peek, you would have noticed something L1 cache latency ** and L2 cache latency **. Have you ever wondered what latency means and why it the most crucial word of our times.
Latency can make or break a device because nobody would like to own a slow PC/laptop. In a computer network, latency is defined as the amount of time it takes for a packet of data to get from one designated point to another. Latency in simple terms mean wasted time. The less the latency, the better the communication between the two nodes in any device.
In more general terms, it is the amount of time between the cause and the observation of the effect. Latency greatly affects how usable and enjoyable electronic and mechanical devices as well as communications are.
Latency in communication is demonstrated in live transmissions from various points on the earth as the communication hops between a ground transmitter and a satellite and from a satellite to a receiver each take time.
As you would expect, latency is important, very important. As programmers, you must be knowing the fact that reading from disk takes longer than reading from memory. Another interesting fact about computers is that L1 cache is faster than the L2 cache.
- In general, the period of time that one component in a system is spinning its wheels waiting for another component. Latency, therefore, is wasted time. For example, in accessing data on a disk, latency is defined as the time it takes to position the proper sector under the read/write head.
- In networking, the amount of time it takes a packet to travel from source to destination. Together, latency and bandwidth define the speed and capacity of a network.
- In VoIP terminology, latency refers to a delay in packet delivery. VoIP latency is a service issue that is usually based on physical distance, hops, or voice to data conversion.
But do you know the orders of magnitude by which these aspects are faster/slower compared to others?
The table below presents the latency for the most common hardware operations. These data are only approximations and will vary with the hardware and the execution environment of your code. However, they do serve their primary purpose, which is to enable us make informed technical decisions to reduce latency.
For better comprehension of the multi-fold increase in latency, scaled figures in relation to L2 cache are also provided by assuming that the L1 cache reference is 1 sec.
|L1 cache reference||Level-1 cache, usually built onto the microprocessor chip itself.||0.5 ns||Consider L1 cache reference duration is 1 sec|
|Branch mispredict||During the execution of a program, CPU predicts the next set of instructions. Branch misprediction is when it makes the wrong prediction. Hence, the previous prediction has to be erased and new one calculated and placed on the execution stack.||5 ns||10 s|
|L2 cache reference||Level-2 cache is memory built on a separate chip.||7 ns||14 s|
|Mutex lock/unlock||Simple synchronization method used to ensure exclusive access to resources shared between many threads.||25 ns||50 s|
|Main memory reference||Time to reference main memory i.e. RAM.||100 ns||3m 20s|
|Compress 1K bytes with Snappy||Snappy is a fast data compression and decompression library written in C++ by Google and used in many Google projects like BigTable, MapReduce and other open source projects.||3,000 ns||1h 40 m|
|Send 1K bytes over 1 Gbps network||10,000 ns||5h 33m 20s|
|Read 1 MB sequentially from memory||Read from RAM.||250,000 ns||5d 18h 53m 20s|
|Round trip within same datacenter||We can assume that the DNS lookup will be much faster within a datacenter than it is to go over an external router.||500,000 ns||11d 13h 46m 40s|
|Read 1 MB sequentially from SSD disk||Assumes SSD disk. SSD boasts random data access times of 100000 ns or less.||1,000,000 ns||23d 3h 33m 20s|
|Disk seek||Disk seek is method to get to the sector and head in the disk where the required data exists.||10,000,000 ns||231d 11h 33m 20s|
|Read 1 MB sequentially from disk||Assumes regular disk, not SSD. Check the difference in comparison to SSD!||20,000,000 ns||462d 23h 6m 40s|
|Send packet CA->Netherlands->CA||Round trip for packet data from U.S.A to Europe and back.||150,000,000 ns||3472d 5h 20m|