Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lock-free bounded queue #83

Closed
wants to merge 1 commit into from
Closed

Conversation

polytypic
Copy link
Contributor

@polytypic polytypic commented Jul 14, 2023

This implements a lock-free bounded queue — blocking using domain-local-await.

The data structure / algorithm is based on the Michael-Scott queue extended with length maintenance and caching of remaining capacity in such a way that additional contention is avoided in the happy paths.

TODO:

  • fix opam files to build on CI
  • use backoff from separate package
    • fix dune-project
  • try_push, length (can be done in O(1)), is_empty
  • tests
  • ability to change capacity
  • benchmarking
  • consider whether making wakeups fair is worth it (currently all awaiters are woken up so there is no fairness)
  • documentation

@polytypic polytypic force-pushed the lock-free-bounded-queue branch 3 times, most recently from 3bee128 to 79f3692 Compare July 15, 2023 19:54
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 79f3692 to d6bc981 Compare July 27, 2023 13:08
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from d6bc981 to 98804fa Compare August 21, 2023 07:50
@polytypic polytypic force-pushed the lock-free-bounded-queue branch 4 times, most recently from d4b7e51 to e548e50 Compare November 3, 2023 13:31
@polytypic polytypic force-pushed the lock-free-bounded-queue branch 2 times, most recently from 0084799 to 2aae21c Compare November 20, 2023 17:59
@polytypic polytypic force-pushed the lock-free-bounded-queue branch 4 times, most recently from 261eabb to 928660b Compare January 11, 2024 14:40
@polytypic polytypic force-pushed the lock-free-bounded-queue branch 2 times, most recently from 12a77c7 to 46c2cae Compare January 14, 2024 12:28
@lyrm lyrm mentioned this pull request Jan 24, 2024
12 tasks
@Sudha247 Sudha247 added this to the 1.0 milestone Jan 29, 2024
@polytypic polytypic force-pushed the lock-free-bounded-queue branch 3 times, most recently from b47847c to 3749cbf Compare February 17, 2024 17:22
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 3749cbf to 5e7d637 Compare March 1, 2024 10:16
@polytypic
Copy link
Contributor Author

FYI, I will squash this PR to a single commit to make this PR a little bit easier to work with.

@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 734c367 to 47cdeb1 Compare March 1, 2024 11:49
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 47cdeb1 to 4accc07 Compare March 1, 2024 13:52
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 4accc07 to 3f75aea Compare March 13, 2024 07:47
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 3f75aea to 5565737 Compare April 2, 2024 16:19
@polytypic polytypic force-pushed the lock-free-bounded-queue branch 2 times, most recently from 01f316b to 55485fd Compare September 29, 2024 08:57
@polytypic polytypic force-pushed the lock-free-bounded-queue branch from 55485fd to 72af6bf Compare September 29, 2024 09:08
@polytypic
Copy link
Contributor Author

FYI, I changed this to use Picos instead of DLA.

@lyrm lyrm mentioned this pull request Nov 15, 2024
7 tasks
lyrm added a commit that referenced this pull request Nov 23, 2024
* Bounded queue from PR #83 : remove blocking part

* Add tests

* Add drop_exn, is_full and of_list_exn  function.

* Add benches

* Add examples in doc.
@lyrm
Copy link
Collaborator

lyrm commented Nov 23, 2024

#160 has been merged and adds this implementation without the bounding part. For now, we are not planning to add a dependency to picos so I close this PR.

Thanks @polytypic for the work !

@lyrm lyrm closed this Nov 23, 2024
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.

4 participants