Skip to content

snwfog/persistent.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

persistent.go

- lockfree linked-list
- lockfree queue (todo)
- gc to clean up resources (todo)

motivation

- play with golang pointer and unsafe (gasp!)
- actually need this and benchmark (see below), over a map+mutex, sync.map, or load/store
- other implementations found on github were difficult to understand

caveat

- list is actually a set -> duplicate key not allowed

commands

- go generate ./internal

results

- Map size=5000, List size=5000
go test -run=XXX -bench=Benchmark -benchmem -v ./pkg/campaign
goos: darwin
goarch: amd64
pkg: github.com/snwfog/persistent.go/pkg/campaign
BenchmarkCampaignCopyMap-8                                 	   55994	     21321 ns/op	       2 B/op	       0 allocs/op
BenchmarkCampaignCopyLinkedList-8                          	100000000	        11.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkCampaignCopyParallelMapLock-8                     	   53666	     22340 ns/op	      18 B/op	       0 allocs/op
BenchmarkCampaignCopyParallelList-8                        	13457457	        86.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkCampaignCopyParallelMapLockWithCampaignInsert-8   	   45645	     22960 ns/op	      25 B/op	       0 allocs/op
BenchmarkCampaignCopyParallelListWithCampaignInsert-8      	13552542	        86.8 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/snwfog/persistent.go/pkg/campaign	10.564s

related

- https://github.com/zond/gotomic
- https://github.com/jserv/concurrent-ll (C)
- https://github.com/cornelk/hashmap (Go)

links

- http://www.rossbencina.com/code/lockfree
- http://15418.courses.cs.cmu.edu/spring2013/article/46
- https://preshing.com/20120612/an-introduction-to-lock-free-programming/
- https://en.wikipedia.org/wiki/Non-blocking_algorithm
- https://en.wikipedia.org/wiki/Non-blocking_linked_list
- https://github.com/cornelk/go-benchmark

license

https://en.wikipedia.org/wiki/WTFPL

powered by awesome folks at https://www.jetbrains.com

About

Lockfree list and queue in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published