Chapter 14Concurrency Primitives MeasuredPaid chapter

sync Primitives: Workload-Specific Tradeoffs

Choose synchronization primitives from measured workload behavior and documented contracts.

Launch paywall

This chapter is part of the paid launch. The preview stays visible so readers can evaluate the exact scope before buying.

Included in

Core and Complete. Complete also includes the practical exam and free Go-version updates.

Preview

What this chapter teaches

Common belief

RWMutex is faster for reads, sync.Map is the concurrent map, and sync.Pool manages a pool of reusable memory you can rely on.

What actually happens

lock and map costs depend on the read/write mix, key overlap, critical-section work, core count, and Go implementation. The supplied benchmark favors RWMutex and sync.Map; another workload may favor a plain locked map. sync.Pool is a cache whose contents may disappear, so correctness must never depend on a pooled object being present. sync.Once has a short warm path, but its cost still belongs in a measurement when it matters.

Mechanisms covered
Go 1.24 replaced the old read/dirty sync.Map implementation with a hash trie.
Pool entries may disappear; a timed mutex wait alone does not identify an internal mode transition.
benchexperiment
One-time purchase

Unlock Chapter 14 and the rest of the course.

Core unlocks every paid chapter and lab. Complete also includes the practical exam and future Go-version updates.

Core
$49

Full course access with the complete mechanics curriculum.

All paid chapters unlocked
One-time purchase
Perfect if you want the material only
Complete
$79
Best value

Best-value launch option with the exam and free Go-version course updates.

Everything in Core
Black Belt practical exam
Free Go-version updates

No subscription or account required. Access is tied to the email entered at Stripe Checkout and can be restored by email.

Free chapter
Escape Analysis: The Compiler's Fragile Decision
Distinguish escape diagnostics from measured allocations and explain the role of lifetime and call-site visibility.
Free chapter
Maps: Swiss Tables, Growth, and Permanent Memory
Distinguish map table capacity from referenced payloads and inspect clearing and growth on Go 1.25.