ocaml-multicore / kcas

Software Transactional Memory for OCaml
https://ocaml-multicore.github.io/kcas/
ISC License
109 stars 11 forks source link

Suggestions for first-time contributors to k-CAS #31

Open polytypic opened 1 year ago

polytypic commented 1 year ago

The kcas library currently lacks benchmarks, tests, and cool examples and those can also serve as a good way to understand k-CAS itself. The kcas_data library provides a few data structures, but there is plenty of room for more.

Here are some potential ideas:

dangdennis commented 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.

polytypic commented 1 year ago

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.