DEV Community

compilersutra
compilersutra

Posted on Originally published at compilersutra.com

Know Your Silicon: Why CPU Info Matters for Honest Performance

CompilerSutraPerf episode cover

Why this lesson exists

When you blame a compiler for a slowdown you’re often ignoring the silicon that actually executed the code. Without a record of the CPU model, stepping‑through, or micro‑architecture, you can’t tell if a change is real or just a quirk of a different chip.

Recap — where we are in the series

The misconception

Many developers look at a single timing and assume the compiler is the culprit. They ignore that the same binary can run on a 2 GHz Ivy Bridge or a 3.5 GHz Rocket Lake, and the difference is entirely silicon‑driven.

What problem csperf solves (this episode's slice)

csperf cpuinfo and csperf deviceinfo capture the exact CPU model, stepping, and micro‑architecture. By attaching that metadata to every run you can:

  1. Verify that two runs used the same silicon.
  2. Attribute performance differences to real compiler changes, not hardware.
  3. Provide reproducible evidence that others can audit.

Mental model

Think of a performance run as a photograph. The picture (execution time) is useless without the camera settings (CPU model, stepping, cache size). csperf cpuinfo is the camera’s EXIF data.

Lab: install and first commands

# Install csperf if you haven’t already
pip install compilersutra-perf

# Quick sanity check
csperf doctor

# Capture the silicon details
csperf cpuinfo
csperf deviceinfo
Enter fullscreen mode Exit fullscreen mode

The output will include fields like model_name, stepping, microarchitecture, and cache_size.

Lab: what we ran on this machine

We ran a small matrix multiplication benchmark (matrix_traversal.cpp) on a 2023‑mid‑year Intel i7‑12700K. The artifact shows:

  • CPU: Intel(R) Core(TM) i7‑12700K
  • Stepping: 10
  • Microarchitecture: Alder Lake
  • Cache size: 25 MiB L3

The csperf run command automatically attaches this data to the artifact.

Results (real numbers only)

Trial wall times from this csperf run

Graph: trial wall_time_ms from this run's artifacts (not invented).

Artifacts missing for this episode — numbers withheld.

How to read the artifacts

Open the JSON artifact with csperf visualize or inspect the metadata section. Look for:

  • cpuinfo → model_name, stepping, microarchitecture
  • deviceinfo → cache_size, num_cores, architecture These fields are the keys that tie a timing to a specific silicon.

Common mistakes (teacher checklist)

  1. Skipping cpuinfo – you’ll have no silicon record.
  2. Running on different machines – compare artifacts, not raw times.
  3. Ignoring stepping – two chips of the same model can differ by a few percent.
  4. Assuming the same cache size – cache hierarchy changes across generations.

Try this next (homework)

Do this tonight — Episode 24 starts by assuming you did.

Closing

Knowing your silicon is the first step toward honest performance claims. Without it, you’re just guessing.

The series so far

References

Top comments (0)