Open polytypic opened 1 year ago
I see there’s already a PR that uses ocurrent’s benchmark tools. Is this for certain?
I have an initial MVP here that uses hyperfine instead. https://github.com/dangdennis/kcas/pull/1
Thanks for the lib! I’ve always been curious how Haskell‘s STM worked but couldn’t ever understand the code much.
Sorry for taking a long time to reply!
I see there’s already a PR that uses ocurrent’s benchmark tools. Is this for certain?
It is work in progress. The benchmarking infrastructure has not previously supported parallel benchmarks and I guess there is still work to do there. I will likely be taking over the integration work.
Currently there are some simple benchmarks developed while working on the library and I have indeed been using hyperfine to run those (you can see results of benchmark runs in various PRs, e.g. here is a recent one). It is very useful to have some benchmarks to check that changes do not cause obvious performance regressions and also to test whether potential improvements are as expected. The set of benchmarks is far from comprehensive, however.
For better or worse, I think that the most wanted kind of benchmarks would be benchmarks that compare performance of kcas and and kcas_data data structures against plain atomics, lock-free data structures, and lock based data structures. The goal being to understand what is the overhead / cost of the composability. Writing such comparative benchmarks tends to be difficult as it is easy to create biased benchmarks. Also, there currently isn't a really good lock implementation for OCaml — one that would be scheduler independent and friendly. There is work in progress towards that, however.
The
kcas
library currently lacks benchmarks, tests, and cool examples and those can also serve as a good way to understand k-CAS itself. Thekcas_data
library provides a few data structures, but there is plenty of room for more.Here are some potential ideas:
Using k-CAS, create examples of solutions to well known concurrency problems such as
Implement examples and benchmarks of lock-free data structures:
Stack
); what about something using an array?Queue
), but there are many ways to implement queuesDllist
); what about singly linked lists?Hashtbl
), but there is definitely room for moreNote that with k-CAS it is possible to straighforwardly translate an imperative data-structure to a lock-free data-structure by using transactions.
Use k-CAS to implement composable synchronization primitives (mutexes, condition variables, semaphores, barriers, ...) with the idea being that one can commit a transaction that e.g. simultaenously acquires multiple mutexes
Use k-CAS e.g. with
domainslib
to parallelize algorithms that e.g. manipulate non-trivial data structures and are difficult to parallelize otherwise.Device tests / benchmarks / examples that perform particularly poorly, e.g.
commit ~mode:Mode.obstruction_free
and significantly better withcommit ~mode:Mode.lock_free
, or