Coder Social home page Coder Social logo

denniscorvers / lockless-queue Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 1.0 131 KB

A collection of lockless, concurrent queues

License: MIT License

C# 100.00%
queue lockless thread-safe-queue spsc-queue mpsc-queue mpmc-queue unity unity3d disruptor ringbuffer

lockless-queue's Introduction

LocklessQueue

A collection of concurrent collections which are not found in the .Net framework.

Available on NuGet via Install-Package Lockless-Queue

The following collections are present:

  • ConcurrentHashSet (based on .Net ConcurrentDictionary)
  • SPSC Queue (Single Producer, Single Consumer).
  • MPSC Queue (Multi Producer, Single Consumer).
  • MPMC Queue (Multi Producer, Multi Consumer).

Benchmarks

All benchmarks are run in a .Net 5.0 environment.

Queues

ConcurrentQueue and Queue are the built-in .Net types.

The following Benchmarks execute Enqueueing 128 items, Dequeueing 128 items and finally clearing the Queue. The same methods are used for each queue where available. All Queue benchmarks are run in a single-threaded environment to demonstrate the "raw" throughput of each queue.

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
MPMCQueue 2,353.5 ns 2.55 ns 2.39 ns - - - -
SysConcurrentQueue 2,860.8 ns 7.00 ns 6.21 ns 0.5188 0.0076 - 4352 B
MPSCQueue 1,619.6 ns 9.52 ns 8.91 ns - - - -
SPSCQueue 555.9 ns 1.39 ns 1.23 ns - - - -
Queue 625.1 ns 1.95 ns 1.82 ns - - - -

HashSet

A comparison is made between the ConcurrentDictionary (when using a byte as value) and the ConcurrentHashSet implementation. The following benchmarks execute TryAdd 128 items, TryRemove 128 items and finally clearing the collection. The benchmarks are run in a single-threaded environment.

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
ConcurrentDictionary 60.580 μs 0.0796 μs 0.0621 μs 3.6621 0.0610 - 30.14 KB
ConcurrentHashSet 7.990 μs 0.0104 μs 0.0087 μs 0.6104 - - 5 KB

lockless-queue's People

Contributors

denniscorvers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

netsmallhao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.