0

As part of some analysis of JVM STM frameworks, I am considering re-engineering an open source library's locking mechanisms to using STM instead. I would then run some tests to compare performance, ease of coding etc.

Obviously the performance tests would have to favour STM's optimistic locking but can work out the semantics of that later.

However, for now, I am just interested in open source library candidates. One that springs to mind is EhCache as it has internal locking measures.

What else might be suitable candidates?

1 Answer 1

1

I would assume that STM

  • produces more elegant code however
  • it is much slower than reasonable use of locks. It can be so much slower that it's slow than writing single threaded code without locks.

Note: STM relocking can get into a situation like a deadlock where it never obtains all the locks it needs.

You are likely to find than STM is too immature to provide performance advantages.

Sign up to request clarification or add additional context in comments.

8 Comments

Possibly, but my analysis will be a comparison of 2 STM technologies, so I am looking to find a non-trivial way to implement STM and then test this out. Need something more advanced than the classic bank transferral examples
You should find an example which is actually faster using multiple threads. e.g. the classic bank transfer example is faster with just one thread as the locking is much more expensive than the operation it performs. The whole point of having concurrency is to improve performance, not make it more complicated AND slower.
A simple example of when multiple threads is faster is large matrix multiplication, but I doubt it's a good idea to use STM for that. ;)
I don't know of a good situation for using STM, all the examples I have seen would be better written single threaded if simplicity was a priority.
@Peter, I've found STM to be no more elegant than regular locking (IMO). The syntactic sugar of say Akka helps highlight what blocks of code should be atomic but I've found it difficult to achieve the same elegance when atomicity is required across multiple classes/business processes.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.