You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/athletictuxe/lfmap

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/athletictuxe/lfmap

v0.0.0-20250310164649-d73268310f1f
Source
Go
Version published
Created
Source

lfmap

Go Reference

Generic concurrent lock-free map for Golang.

Key features:

  • range iteration over consistent snapshot of map without locking other threads and without copying all data in map to maintain that snapshot.
  • Convenient transactions where you can read-write multiple keys, check some conditions and make a change based on your logic. Compared to lfmap, sync.Map allows only CAS operations against single key and that's it.

Usage

See godoc examples.

Benchmarks

goos: linux
goarch: amd64
pkg: github.com/athletictuxe/lfmap
cpu: Intel(R) N100
BenchmarkLFMapSet-4              	  165698	     11190 ns/op
BenchmarkSyncMapSet-4            	  857448	      2302 ns/op
BenchmarkLFMapGet-4              	 3221922	       365.1 ns/op
BenchmarkSyncMapGet-4            	 5302554	       189.9 ns/op
BenchmarkLFMapRange1000000-4     	       8	 142530076 ns/op
BenchmarkSyncMapRange1000000-4   	       7	 150277709 ns/op
PASS
ok  	github.com/athletictuxe/lfmap	31.614s

So far lfmap is 2-6 times slower than sync.Map, mostly because of underlying immutable ds performance. However, nice transactional properties may make it useful.

FAQs

Package last updated on 10 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts