Datomic stores the entire database in an atom (not an STM ref), and updates it with a call to swap! It is literally no more complex than a trivial hackneyed book example. :-)
A lot of my systems have evolved into something similar and I've wondered what the implications of this approach are. As more and more state is added to this single atom and with multiple threads performing swap!s (CASs) how will performance be effected? i.e. How will write contention play out in a system designed like this? I'm sure the answer to this depends on the details of the system but at what point does this become a problem?
In the epic thread about the STM between Rich and Cliff Click[1] the main argument against the STM was that it didn't help solve the problem of where to place guards around the data. From one of Cliff's arguments:
In a trivial example I can say “go up one call level and atomic there”, but in the Real Program – I can’t do that. Go up how many layers and add atomic? 1 layer? 10 layers? 100 layers? Yes, I see unique call-stacks with >100 layers. I can’t put atomic around main because that makes my program single-threaded.
I believe Cliff is arguing here that when a program pushes all of the state into a single atom where a lot of writes occur that app effectively is single-threaded. (Please correct me if I am misunderstanding!) Thoughts?
-Ben 1. http://www.azulsystems.com/blog/cliff/2008-05-27-clojure-stms-vs-locks -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en