---
title: "Pick the right map"
---

> Documentation Index
> Fetch the complete documentation index at: https://example.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pick the right map

Map choice decides both CPU scalability and memory footprint. Use `PERCPU` maps for counters and histograms, `LRU_PERCPU_HASH` for dynamic keys like cgroups, and `RINGBUF` for ordered event streams.

Reserve shared `HASH` maps only for low-frequency slow paths (like direct memory reclaim or control-plane updates) where cross-CPU visibility matters more than lock-free throughput.

## Map type cheat sheet

|  | PERCPU_ARRAY / LRU | HASH | RINGBUF |
| --- | --- | --- | --- |
| Best for | Hot counters | Shared state | Packet/event stream |
| Locking | Lock-free | Bucket spinlock | Lock-free reserve |
| Ordering | Aggregated | Point lookup | Global FIFO |
| Read cost | Sum N CPUs | 1 lookup | mmap poll |

Source: https://example.com/ebpf-field-guide/core-architecture/maps-and-data/recap/index.mdx
