Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

One disadvantage of implementing Semaphore in terms of TSemaphore is that STM transactions may be retried in an arbitrary order, so a Semaphore implemented this way does not provide a guarantee that earlier attempts to acquire a permit will succeed before later attempts when a permit becomes available. We can fix this by implementing Semaphore directly. In addition, this implementation is faster.

[info] Benchmark                                (fibers)  (ops)   Mode  Cnt    Score   Error  Units
[info] SemaphoreBenchmark.semaphoreContention         10   1000  thrpt   15  189.984 ± 0.524  ops/s
[info] SemaphoreBenchmark.tsemaphoreContention        10   1000  thrpt   15   82.308 ± 0.715  ops/s

@adamgfraser adamgfraser requested review from jdegoes and vigoo November 20, 2023 20:14
@jdegoes jdegoes merged commit ac49006 into zio:series/2.x Nov 20, 2023
@adamgfraser adamgfraser deleted the semaphore branch November 20, 2023 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants