← Lessons

quiz vs the machine

Platinum1780

Concurrency

The CPU Pinning And Isolation

Binding a thread to specific cores and keeping the OS off them for steady performance.

6 min read · advanced · beat Platinum to climb

Choosing where a thread runs

By default the scheduler may move a thread between cores. CPU pinning, also called setting affinity, binds a thread to one core or a small set of cores so it stops migrating.

Why migration hurts

  • Each core has its own fast cache. When a thread moves, the new core's cache is cold, so it stalls reloading data.
  • Migrations also disturb branch predictors and other per core state.

Pinning keeps a thread's working set warm in one core's cache, which lowers and stabilizes latency.

Core isolation

For the most demanding work you go further and isolate a core. The OS is told to keep its normal threads and timer interrupts off that core, reserving it almost entirely for one pinned thread. Background kernel work runs elsewhere.

The trade off

Isolation gives one thread a near dedicated core with very steady timing, but it removes that core from the general pool. If your isolated thread is often idle, you have wasted capacity. It pays off only for latency critical paths that must run without interference.

Key idea

CPU pinning binds a thread to a core to keep its cache warm and timing steady, while core isolation reserves that core from the OS for latency critical work at the cost of general capacity.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does pinning a thread to a core help performance?

2. What does core isolation do?

3. What is the main cost of isolating a core?