[ANN] kcas and kcas_data 0.6.1: STM and compositional lock-free data structures

I’m happy to announce that version 0.6.1 of kcas and kcas_data has been released on opam.

See the Kcas project for more details, but briefly kcas provides a software transactional memory (STM) implementation and kcas_data provides compositional lock-free data structures implemented using Kcas. Together these libraries allow one to implement safe concurrent abstractions compositionally.

Aside from internal improvements, notable features added since the previously announced 0.3.0
version include:

Stay tuned for more news on Kcas!


An STM is not the way to write scalable parallel code.
Eventually, threads will start walking on each other’s toes, each thread cancelling
the work produced by the previous thread.
Backtracking work that has already been done is not the way to move a computation forward.

You need semaphores, you also need to know who needs access to what and with which permission.

I once saw the two best programmers I ever worked with in my entire career throw away a big bunch of code once they realized that the hard way.

1 Like

Thanks for your detailed answer, after mostly an annoyed remark from my side.

I am curious: why do you reimplement a semaphore module in your answer?
Doesn’t ocaml-5 already provides highly optimized semaphores in the stdlib to synchronize domains?

Retries is also a bad thing; it is usually called “busy waiting”: a not very smart and inefficient method
(it wastes CPU cycles instead of locking the thread then unlocking it at the proper time later,
leaving the CPU free for another thread to do some work in between).

IIUC kcas uses backoff mechanism/algorithm to reduce CPU “busy waiting”.

1 Like