How gebi/cowmap works
This is a generic, in-memory concurrent Go map using 64 sharded HAMT roots. Clients invoke lookup, iteration, insertion, and deletion through Map. Each operation hashes and routes a key to one shard. Reads load an atomic root and traverse immutable bitmap nodes, while writers clone affected paths and publish them with CAS retries. Collision buckets handle identical hashes, and iterators traverse per-shard root snapshots. The graph represents the single sampled runtime file; no external persistence or service layer exists.
Components 12
Map API
- Map Operations
cowmap.go - Hash Strategy
cowmap.go - Snapshot Reader
cowmap.go - Snapshot Iterator
cowmap.go
Concurrency State
- CAS Writers
cowmap.go - Shard Roots
cowmap.go - CAS Backoff
cowmap.go
HAMT Engine
- Bitmap Trie Nodes
cowmap.go - Path Copying
cowmap.go - Structural Deletion
cowmap.go - Collision Buckets
cowmap.go
Other components
- Client
Connections 21
- Client → Map Operations: invokes
- Map Operations → Hash Strategy: hashes keys
- Map Operations → Snapshot Reader: dispatches reads
- Map Operations → Snapshot Iterator: dispatches iteration
- Map Operations → CAS Writers: dispatches writes
- Snapshot Reader → Shard Roots: loads roots
- Snapshot Reader → Bitmap Trie Nodes: traverses trie
- Snapshot Reader → Collision Buckets: scans buckets
- Snapshot Iterator → Shard Roots: loads snapshots
- Snapshot Iterator → Bitmap Trie Nodes: iterates nodes
- Snapshot Iterator → Collision Buckets: iterates buckets
- CAS Writers → Shard Roots: CAS publishes
- CAS Writers → Path Copying: inserts paths
- CAS Writers → Structural Deletion: deletes paths
- CAS Writers → CAS Backoff: retries with
- Path Copying → Bitmap Trie Nodes: clones paths
- Path Copying → Collision Buckets: creates buckets
- Structural Deletion → Bitmap Trie Nodes: prunes paths
- Structural Deletion → Collision Buckets: updates buckets
- Hash Strategy → Shard Roots: routes by hash
- Shard Roots → Bitmap Trie Nodes: stores immutable roots