liveBook · Manning

Thread-per-core

As explained in Latency

Thread-per-core is a concurrency design in which a dedicated execution thread is assigned to each processor core.

Thread-per-core assigns one continuously running thread to each CPU core, pins each thread to its core, and handles concurrency within the application rather than through routine operating-system scheduling. section 7.5.1 section 10.4.1

Each thread processes tasks from a work queue without yielding to another thread. This keeps core-local caches warm and avoids context-switching latency and its unpredictable spikes, but it requires every operation to be non-blocking. section 10.4.1 section 7.5.1

Use the design when its constraints match the workload:

  • Combine dedicated threads with application-level concurrency such as coroutines or futures and promises. section 7.5.1
  • Prefer it for event-driven architectures and asynchronous I/O workloads where blocking would otherwise stall a core. section 10.4.1
  • Avoid it for traditional blocking I/O patterns, where a thread pool remains necessary. section 10.4.1
  • Partition data for suitable CPU access when multicore memory topology makes DRAM latency non-uniform. section 3.1

Asynchronous runtime

A runtime modeled on Seastar assigns one thread to each core and feeds each thread tasks from a work queue, using non-blocking operations to sustain low-latency processing. section 10.4.1

How Latency covers it

How deep it goes
Defines core assignment, pinning, queues, locality, and blocking constraints, but does not detail runtime implementation.
Examples
Uses work queues, coroutines, futures and promises, Seastar, ScyllaDB, and multicore DRAM partitioning as concrete examples.
What it assumes
Assumes CPU-core and thread basics while establishing context-switching costs, blocking constraints, and multicore locality.
What you can do after
Apply it via pinned worker threads, application-level concurrency, work queues, and non-blocking operations.
How it connects
Connects CPU affinity, context switching, coroutines, futures and promises, thread pools, asynchronous I/O, and data locality.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.