-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme
56 lines (40 loc) · 1.9 KB
/
readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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