Tag

sync.Map

0 views collected around this technical thread.

Go Programming World
Go Programming World
Feb 11, 2025 · Backend Development

Deep Dive into Go's sync.Map: Implementation, Usage, and Performance

An in‑depth exploration of Go’s sync.Map reveals its concurrent map implementation, covering core structures, read‑only and dirty maps, entry states, and detailed walkthroughs of Store, Load, Delete, Range, Clear, and advanced operations like LoadOrStore, CompareAndSwap, and CompareAndDelete with code examples.

BackendGoconcurrency
0 likes · 30 min read
Deep Dive into Go's sync.Map: Implementation, Usage, and Performance
37 Interactive Technology Team
37 Interactive Technology Team
Jun 15, 2023 · Backend Development

Concurrent Safety of Go Maps: Issues, Solutions, and Performance Comparison

Go maps are not safe for concurrent access, so programs can panic when multiple goroutines read and write the same map; to prevent this you can use sync.Once for immutable data, protect maps with sync.RWMutex, employ sharded locks via concurrent‑map, or use the built‑in sync.Map, each offering different performance trade‑offs depending on read/write ratios and concurrency level.

Goconcurrencymap
0 likes · 13 min read
Concurrent Safety of Go Maps: Issues, Solutions, and Performance Comparison
Baidu Geek Talk
Baidu Geek Talk
Feb 1, 2023 · Backend Development

Practical Generic Programming Techniques in Go Language

This article explains Go 1.18 generics—type parameters, type‑set interfaces, and inference—through six practical examples including a universal sorting function, generic Append, heap, sync.Pool and sync.Map wrappers, showing how generics reduce code size, improve readability, and enhance type safety.

Generic containersGo 1.18Go generics
0 likes · 22 min read
Practical Generic Programming Techniques in Go Language
Tencent Cloud Developer
Tencent Cloud Developer
Jun 13, 2022 · Backend Development

Analysis of Go's sync.Map Implementation: Design, Architecture, and Source Code Walkthrough

The article explains how Go’s sync.Map achieves high‑concurrency performance by maintaining a lock‑free read‑only snapshot in an atomic.Value and a mutex‑protected dirty map, detailing entry state transitions, miss‑driven promotion, and the Store, Load, and Delete operations that together avoid a global lock.

AtomicData StructuresGo
0 likes · 18 min read
Analysis of Go's sync.Map Implementation: Design, Architecture, and Source Code Walkthrough
Tencent Cloud Developer
Tencent Cloud Developer
Jun 8, 2022 · Backend Development

Understanding Go Map and Slice Concurrency Safety and Parameter Passing

The article explains that Go maps and slices are not safe for concurrent reads or writes, describes how the runtime detects map violations, and recommends using sync.Mutex, sync.RWMutex, or sync.Map for maps and external synchronization for slices, while also clarifying that passing these reference types to functions shares underlying data unless explicitly copied.

Goconcurrencylocking
0 likes · 12 min read
Understanding Go Map and Slice Concurrency Safety and Parameter Passing
Tencent Cloud Developer
Tencent Cloud Developer
Dec 22, 2021 · Backend Development

Performance Analysis of Go map Concurrency: sync.Map vs map+RWLock vs concurrent‑map

The article compares Go’s native map (which crashes under concurrent access), a map protected by sync.RWMutex, the lock‑free read‑optimized sync.Map introduced in Go 1.9, and the sharded orcaman/concurrent‑map, showing that sync.Map excels in read‑heavy workloads while sharded maps better handle frequent inserts, and suggesting other cache libraries for eviction or expiration needs.

CacheGoconcurrency
0 likes · 20 min read
Performance Analysis of Go map Concurrency: sync.Map vs map+RWLock vs concurrent‑map