All Projects → decillion → go-stm

decillion / go-stm

Licence: MIT License
Software Transactional Memory for Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-stm

Zio
ZIO — A type-safe, composable library for async and concurrent programming in Scala
Stars: ✭ 3,167 (+21013.33%)
Mutual labels:  concurrency, stm
queueable
Convert streams to async ⌛ iterables ➰
Stars: ✭ 43 (+186.67%)
Mutual labels:  concurrency
await async
Provide await and async methods to Crystal Lang
Stars: ✭ 71 (+373.33%)
Mutual labels:  concurrency
async-enumerable-dotnet
Experimental operators for C# 8 IAsyncEnumerables
Stars: ✭ 32 (+113.33%)
Mutual labels:  concurrency
sto
Software Transactional Objects
Stars: ✭ 40 (+166.67%)
Mutual labels:  concurrency
CacheLib
Pluggable in-process caching engine to build and scale high performance services
Stars: ✭ 637 (+4146.67%)
Mutual labels:  concurrency
atomix
Simple and easy wrappers for Go sync/atomic package.
Stars: ✭ 26 (+73.33%)
Mutual labels:  concurrency
edd
Erlang Declarative Debugger
Stars: ✭ 20 (+33.33%)
Mutual labels:  concurrency
multilayer-perceptron
Library to make and train a concurrent multilayer perceptron
Stars: ✭ 46 (+206.67%)
Mutual labels:  concurrency
Async-Channel
Python async multi-task communication library. Used by OctoBot project.
Stars: ✭ 13 (-13.33%)
Mutual labels:  concurrency
transit
Massively real-time city transit streaming application
Stars: ✭ 20 (+33.33%)
Mutual labels:  concurrency
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (+106.67%)
Mutual labels:  concurrency
nativescript-http
The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning
Stars: ✭ 32 (+113.33%)
Mutual labels:  concurrency
learning-stm
Learning structural topic modeling using the stm R package.
Stars: ✭ 103 (+586.67%)
Mutual labels:  stm
cpp stm free
Composable monadic STM for C++ on Free monads
Stars: ✭ 46 (+206.67%)
Mutual labels:  stm
traffic
Massively real-time traffic streaming application
Stars: ✭ 25 (+66.67%)
Mutual labels:  concurrency
aiorwlock
Read/Write Lock - synchronization primitive for asyncio
Stars: ✭ 90 (+500%)
Mutual labels:  concurrency
soabase-stages
A tiny library that makes staged/pipelined CompletableFutures much easier to create and manage
Stars: ✭ 23 (+53.33%)
Mutual labels:  concurrency
psched
Priority-based Task Scheduling for Modern C++
Stars: ✭ 59 (+293.33%)
Mutual labels:  concurrency
channel
Go-like channels for JavaScript
Stars: ✭ 49 (+226.67%)
Mutual labels:  concurrency

go-stm

import "github.com/decillion/go-stm"

Package stm is a software transactional memory implementation for Go, which is based on the Transactional Locking II (TL2) proposed by Dice et al. https://doi.org/10.1007/11864219_14

Documents

See the godoc page for further information. Here is a blog post about go-stm (in Japanese).

Example

// There are two bank accounts of Alice and Bob.
accountA := New(100)
accountB := New(0)

// Transfer 20 from Alice's account to Bob's one.
transfer := func(rec *TRec) interface{} {
	currA := rec.Load(accountA).(int)
	currB := rec.Load(accountB).(int)
	rec.Store(accountA, currA-20)
	rec.Store(accountB, currB+20)
	return nil
}
Atomically(transfer)

// Check the balance of accounts of Alice and Bob.
inquiries := func(rec *TRec) interface{} {
	balance := make(map[*TVar]int)
	balance[accountA] = rec.Load(accountA).(int)
	balance[accountB] = rec.Load(accountB).(int)
	return balance
}
balance := Atomically(inquiries).(map[*TVar]int)
fmt.Printf("The account of Alice holds %v.\nThe account of Bob holds %v.",
	balance[accountA], balance[accountB])
// Output:
// The account of Alice holds 80.
// The account of Bob holds 20.

Benchmark

There exists an another STM package written by lukechampine. The lukechampine's package provides a richer interface but is less efficient than the present package. Here is the result of a very simple benchmark, in which two transactional variables are atomically incremented or read. The benchmark is taken at a DigitalOcean's High CPU Droplet with 32 cores.

Benchmark_Read90Write10_decillion-2      	10000000	       230 ns/op
Benchmark_Read90Write10_decillion-4      	10000000	       156 ns/op
Benchmark_Read90Write10_decillion-8      	10000000	       144 ns/op
Benchmark_Read90Write10_decillion-16       	10000000	       214 ns/op
Benchmark_Read90Write10_decillion-32       	 5000000	       289 ns/op

Benchmark_Read90Write10_lukechampine-2   	 2000000	       715 ns/op
Benchmark_Read90Write10_lukechampine-4   	 2000000	       761 ns/op
Benchmark_Read90Write10_lukechampine-8   	 2000000	       822 ns/op
Benchmark_Read90Write10_lukechampine-16    	 2000000	       912 ns/op
Benchmark_Read90Write10_lukechampine-32    	 2000000	       966 ns/op
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].