Questions tagged [stm]

Software transactional memory (STM) is a mechanism for synchronization in concurrent programming, which can perform groups of memory operations atomically. Using transactional memory (implemented by optimistic synchronization) instead of locks removes the risk of a deadlock.

182 questions
62
votes
6 answers

Any Real-World Experience Using Software Transactional Memory?

It seems that there has been a recent rising interest in STM (software transactional memory) frameworks and language extensions. Clojure in particular has an excellent implementation which uses MVCC (multi-version concurrency control) rather than a…
Daniel Spiewak
  • 52,267
  • 12
  • 104
  • 120
62
votes
1 answer

One processing conduit, 2 IO sources of the same type

In my GHC Haskell application utilizing stm, network-conduit and conduit, I have a strand for each socket which is forked automatically using runTCPServer. Strands can communicate with other strands through the use of a broadcasting TChan. This…
kvanbere
  • 3,199
  • 2
  • 19
  • 43
45
votes
2 answers

Difference between TVar and TMVar

I've seen the TVar is a simple container, while the TMVar is the same as an MVar, meaning it has a lock etc, but within the STM monad. I am wondering why would that be necessary, as the idea of the STM is to make locks unnecessary. So which is the…
Lanbo
  • 13,437
  • 14
  • 67
  • 141
39
votes
1 answer

Concurrent generic data structure without deadlocks or resource starvation

I've recently asked a number of questions regarding TVar, and I still have concerns about livelock. So I thought of this structure: Each transaction gets a unique priority (perhaps allocated in order of creation). Transactions attempt to get…
Clinton
  • 20,364
  • 13
  • 59
  • 142
38
votes
2 answers

When/why use an MVar over a TVar

I find TVar's quite easy to work with even though MVar's appear a little simpler, while TVar's a little more featureful. So my question is pretty simple, what condition do I want to go to MVar rather than TVar? I suppose anytime I don't need…
Jimmy Hoffa
  • 5,725
  • 25
  • 50
32
votes
3 answers

How does Clojure STM differ from Haskell STM?

I am trying to find the differences between what Clojure calls an STM and what is implemented in Haskell as STM. Taking the actual language semantic differences aside I am a little confused as Rich Hickey says in his speech that Clojure's…
yazz.com
  • 52,748
  • 62
  • 227
  • 363
25
votes
2 answers

Haskell fast concurrent queue

The Problem Hello! I'm writing a logging library and I would love to create a logger, that would run in separate thread, while all applications threads would just send messages to it. I want to find the most performant solution for this problem. I…
Wojciech Danilo
  • 10,776
  • 13
  • 60
  • 118
23
votes
5 answers

How do you implement Software Transactional Memory?

In terms of actual low level atomic instructions and memory fences (I assume they're used), how do you implement STM? The part that's mysterious to me is that given some arbitrary chunk of code, you need a way to go back afterwards and determine if…
Joseph Garvin
  • 18,725
  • 17
  • 83
  • 150
20
votes
3 answers

Poor performance / lockup with STM

I'm writing a program where a large number of agents listen for events and react on them. Since Control.Concurrent.Chan.dupChan is deprecated I decided to use TChan's as advertised. The performance of TChan is much worse than I expected. I have the…
Tener
  • 5,191
  • 4
  • 23
  • 42
17
votes
4 answers

How should I make a clojure STM program persistent?

I am writing a clojure program which uses the STM. At the moment I am populating the STM (using refs) at startup from a database, and then asynchronously updating the database whenever a dosync transaction succeeds. I have no idea if I am doing this…
yazz.com
  • 52,748
  • 62
  • 227
  • 363
15
votes
3 answers

What algorithms are used in Clojure, Haskell (and other languages) for STM?

As I understand there are several different algorithms for implementing Software Transactional Memory (and this is a quite active research area). Where can I find (without having to dive into source code) which are used in different languages and…
Jay
  • 9,293
  • 6
  • 44
  • 67
14
votes
1 answer

How to discover if a transaction is frequently aborting?

I'm trying to debug a program that uses STM. The ThreadScope readings is pointing out a very high CPU activity as you can see here: So I'm trying to find out if this is happening due to a transaction that frequently aborts. The first thing that I…
luisgabriel
  • 2,383
  • 1
  • 13
  • 10
14
votes
2 answers

Haskell code littered with TVar operations and functions taking many arguments: code smell?

I'm writing a MUD server in Haskell (MUD = Multi User Dungeon: basically, a multi-user text adventure/role-playing game). The game world data/state is represented in about 15 different IntMaps. My monad transformer stack looks like this: ReaderT…
the-konapie
  • 523
  • 2
  • 10
14
votes
1 answer

How do nested dosync calls behave?

What happens when you create nested dosync calls? Will sub-transactions be completed in the parent scope? Are these sub-transactions reversible if the parent transaction fails?
StackedCrooked
  • 32,392
  • 40
  • 137
  • 267
13
votes
1 answer

Optimistic reads and Locking STM (Software Transactional Memory) with C/C++

I've been doing some research on STM (software transactional memory) implementations, specifically on algorithms that utilize locks and are not dependent on the presence of a garbage collector in order to maintain compatibility with non-managed…
Jason
  • 30,174
  • 7
  • 55
  • 73
1
2 3
12 13