DEV Community

Cover image for ⚡ Latency Numbers Every Programmer Should Know
Mohammad Zeya Ahmad
Mohammad Zeya Ahmad

Posted on

⚡ Latency Numbers Every Programmer Should Know

⚡ Latency Numbers Every Programmer Should Know

Understanding the relative speed of different operations in computing is crucial for writing efficient code. Below is a list of key latency numbers, from CPU cache accesses to network round trips.

🏎️ CPU & Memory Operations

Operation Time Emoji Representation
🏷️ L1 cache reference 0.5 ns 🔥 Ultra-fast
🔀 Branch mispredict 5 ns 🔄 Slight penalty
🏷️ L2 cache reference 7 ns 🚀 Fast
🔐 Mutex lock/unlock 100 ns 🔒 Synchronization cost
🎯 L3 cache reference 30 ns 🎯 Moderate speed
🧠 Main memory reference 100 ns 📦 Memory access

📡 Data Compression & Transfer

Operation Time Emoji Representation
📦 Compress 1K bytes with Zippy 10 µs 🗜️ Compression cost
🌐 Send 2K bytes over 1 Gbps network 20 µs 📡 Network transfer
📚 Read 1 MB sequentially from memory 250 µs 📖 RAM read

🏢 Datacenter & Disk Operations

Operation Time Emoji Representation
🏢 Round trip within the same datacenter 500 µs 🔄 Local network
💽 Disk seek (random access on HDD) 10 ms 🛑 Expensive
🌍 Read 1 MB sequentially from the network 10 ms 🌐 Internet speed
💾 Read 1 MB sequentially from SSD 1 ms ⚡ Fast storage
📀 Read 1 MB sequentially from HDD 30 ms 🐢 Slow disk access

🌎 Network & Intercontinental Transfers

Operation Time Emoji Representation
🚀 Packet transmission across the US 50 ms ✈️ Coast-to-coast
🌍 Packet round-trip US → Europe 100 ms 🌐 Intercontinental
🚀 Packet round-trip CA → Netherlands → CA 150 ms 🛰️ Global transfer
🚀 Packet one-way Earth → Mars (at closest distance) 4-24 min 🛸 Interplanetary delay

🔥 Key Takeaways

  • Nanoseconds (ns) ⚡: CPU operations, cache, and memory references.
  • Microseconds (µs) ⏳: Network and data compression operations.
  • Milliseconds (ms) 🐢: Disk access, network round trips.
  • Minutes 🚀: Deep-space communication delays.

🚀 If you found this helpful, follow me for more programming insights!

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay