Giorgi Chapidze
All projects

Research

MVCC-Based STM in Clojure

My bachelor's thesis on transaction retries, consistent snapshots, and commit hooks, backed by a formal model and concurrency benchmarks in Clojure.

ClojureSTMMVCC

Bachelor's thesis

Design and Evaluation of an MVCC-Based STM in Clojure, completed at Kutaisi International University in 2026.

The problem with retrying a side effect

Imagine a bank-transfer transaction that also sends a notification. If a conflict makes the transaction retry, code inside its body can run again, including that notification. Updating shared state atomically does not by itself coordinate the external effect.

The thesis develops a Clojure STM with transaction lifecycle hooks. An application can register work for a successful commit or an aborted attempt, placing the effect at the corresponding boundary.

A model and an implementation

The implementation combines a variant of Transactional Locking II with multiversion concurrency control. Each reference keeps bounded version history, so a reader can look up a value at its transaction's snapshot. Writers claim ownership as they write, then validate and publish under a global commit lock.

The formal-model chapter defines the transaction states and presents an opacity proof. Opacity requires consistent observations even for transactions that eventually abort; checking only successful commits would leave that case uncovered.

Transaction lifecycle

Read-only transactions bypass the global commit lock. Write transactions validate their read set and publish versioned writes while holding it. on-commit handlers run after success; on-rollback handlers run for an aborted attempt before retrying.

A dosync transaction reads versioned snapshots and buffers writes. Read-only transactions commit without the global lock. Writers acquire the commit lock, validate reads, and publish writes with a new version. Successful commits run on-commit handlers; aborted attempts run on-rollback handlers before backing off and retrying.
Clojure STM transaction lifecycle

The implementation chapter follows the reference layout, ownership protocol, retry loop, and hook dispatch.

Reading the research

The repository includes the compiled 54-page thesis, LaTeX sources, and a downloadable implementation snapshot. The archive includes the STM, transaction hooks, tests, benchmark programs, results, and Java Flight Recorder recordings. Its original opusdb.* namespaces match the thesis listings.

Extract stm-v1.zip, enter stm-v1/, and run lein test with a JDK and Leiningen installed. The stm-v1 tag preserves the source snapshot. Build the PDF from the repository root with ./scripts/build-thesis.sh and the documented TeX Live dependencies. The opacity argument concerns the model presented in the thesis; it should not be read as independent verification of every implementation detail.

Lifecycle hooks coordinate effects with transaction outcomes inside the process. They do not, by themselves, provide durable delivery of notifications or other external effects across a process crash.

What the experiments found

The experiments ran with Clojure 1.12.4 and OpenJDK 25.0.2 on a six-core Ryzen 5 7535HS. The contrasting read/write workloads make the design's main tradeoff visible:

Workload4 threads12 threads
Read-heavy: 10% writes533,885 transactions/s1,969,463 transactions/s
Write-heavy: 90% writes637,709 transactions/s257,574 transactions/s

The read-heavy workload benefits from transactions bypassing the commit lock. Profiling attributes the write-heavy bottleneck to that shared lock. In a separate single-threaded transfer benchmark, adding one commit hook changed mean execution time from 1.59 μs to 1.81 μs, about 14% overhead.

These are the thesis's recorded experiments, rather than general throughput guarantees. The conclusion proposes lock striping, adaptive version-history sizing, and more lifecycle hooks as follow-up work.