Repository navigation
Rewrite TBQueue to use arrays - #70
Conversation
|
Could you show the benchmark results please? |
|
Sure, here are my results: The concrete times vary a bit, but the new |
|
Seems good to me. We should look into why CI is consistently failing though (I imagine it's not just this PR but something more fundamental) |
|
Could you rebase on |
748e503 to
3925cc1
Compare
|
I managed to fix the CI up to the point where only ghc-9.6.2 fails (see https://github.com/konsumlamm/stm/actions/runs/6196967418/job/16824613715 on branch https://github.com/konsumlamm/stm/tree/tbqueue-array-ci): Do you have an idea why this happens and how to fix it? |
|
I suspect that This should permit the CI to rebuild |
|
Adding |
|
Benchmarks only get built for GHC >= 8.0, since they use |
Closes #65.
Closes #36 (is included, since it's needed for
newTBQueueIO). Closes #35.I cherry-picked the commit from #36 to keep the author credit.
The new implementation uses
TArray Int (Maybe a). The read index is the next index to read from, the write index is the next index to write to.readTBQueueandwriteTBQueueonly interfere if the queue is full or empty (in which case one of them has to retry anyway), so most of the time they can run concurrently. This new implementation is faster than the old one in all 3 benchmarks.Optimizations:
unsafeReadandunsafeWritefor array accesses (readArrayandwriteArraygenerate 4 (!) comparisons)modby definingincModanddecModSince the array size can only be an
Int, the capacity is also stored as anIntinternally andnewTBQueue/newTBQueueIOerror if the capacity is bigger thanmaxBound :: Int. For that reason, I'd argue that usingNaturalin the API isn't very good (and since this was only changed in 2.5, perhaps it could be changed back in 2.6).newTBQueue/newTBQueueIOnow also error if the capacity is zero, since such a queue is very useless and it would need extra special casing.I also updated the benchmarks (to be able to benchmark my changes) and added a proper cabal benchmark (it needs a separate
stm-bench.cabalfile to avoid cyclic dependencies, since almost everything depends onstm).In the testsuite, I removed
Issue17.hs, which tested behaviour for negative and zero capacities (which are now invalid).Lastly, I added an
hie.yamlfile to for HLS to work properly in this project.