Skip to content

Lock-free per-CPU maps

Step 4 of 8Solution
LOCKING
zero locks
NUMA SCALE
linear
EVICTION
LRU ready
SUMMING
at scrape
  • CPU hook write
  • userspace read / poll
  • ringbuf event stream
Maps & Data Sharing, step 4 of 8

BPF_MAP_TYPE_PERCPU_ARRAY and BPF_MAP_TYPE_LRU_PERCPU_HASH give every CPU core its own private slot for every key. Hooks update their local slot with zero locks and zero atomics.

The user-space daemon sums across 0..num_possible_cpus once per scrape (every 5–15 seconds). That shifts aggregation off the hot packet path entirely.

What changed

  • Shared hash bucket → private slot per CPU core
  • Atomic cache bounce → plain L1-local increment
  • Hot-path work → cold-path summation on scrape

Type to search…

↑↓ navigate↵ selectEsc close