Konsarpoo 4.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Konsarpoo --version 4.0.0
NuGet\Install-Package Konsarpoo -Version 4.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Konsarpoo" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Konsarpoo --version 4.0.0
#r "nuget: Konsarpoo, 4.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Konsarpoo as a Cake Addin
#addin nuget:?package=Konsarpoo&version=4.0.0

// Install Konsarpoo as a Cake Tool
#tool nuget:?package=Konsarpoo&version=4.0.0

Konsarpoo .NET

Konsarpoo build, tests and coverage Coverage Badge GitHub Release Date Nuget GitHub search hit counter

The eco friendly set of array pool based and ref struct collections for netstandard2.1.

Array pool container's storage allocated and recycled back to shared memory pool by default. It has up to 30% overhead on filling out with data and the similar performance for data look up.

Ref struct collections allow you to write high performance and zero allocation data processing code using up to 8mb of memory (1mb is default).

List of generic collections and APIs supported:

  • Array
  • List
  • Map
  • Set
  • Stack
  • Queue

Some extras built in:

  • BitArr
  • Lfu Cache
  • std::vector api
  • Python like APIs. Append methods, + -, equality operators overloaded.
  • Lambda allocation free enumerable extensions

Each array pool collection is serializable by default. It has a class destructor defined and System.IDisposable interface implemented to recycle internal storage on demand or by GC.

Possible use cases of this package:

  • Avoiding allocating large arrays in LOH (please call - KonsarpooAllocatorGlobalSetup.SetGcAllocatorSetup())
  • Managing the available memory by providing custom allocator (please call - KonsarpooAllocatorGlobalSetup.SetDefaultAllocatorSetup([your allocator impl]))
  • Boosting performance if data processing task can be split into a smaller ones and memory allocated per task can fit into the stack.

Nuget

Please use one of the following commands to install Konsarpoo.

Package Manager
PM> Install-Package Konsarpoo -Version 4.0.0
.NET CLI
> dotnet add package Konsarpoo --version 4.0.0

DATA

The universal random access data container. Supports List, Array, Stack and Queue API's. Data<T> has a minor overhead on adding items using default settings and huge advantage of reusing arrays to reduce GC collection time. Implemented as a tree of .NET sub arrays. The array allocator and max size of array length per node may be set up for each instance, globally or globally for T.

The GcArrayPoolMixedAllocator<T> instance is the default array allocator. It takes advantage of GC and pool array. For small arrays with length 65 or less, it uses GC for larger ones the System.Buffers.ArrayPool<T>.Shared class.

MAP

Map<K,V> is generic hashtable collection that supports the built in Dictionary API. To manage Map internal state the Konsarpoo.Collections.Data comes to the stage.

SET

Set<T> was designed to replace the System.Collections.Generic.HashSet container with ArrayPool based collection. Implemented in the same way as the Map<K,V> with keys collections only.

STACK API / QUEUE API

The Konsarpoo.Collections.Data class supports Stack and Queue API with linear time performance for modifying methods. To access Queue API it is required to call Data.AsQueue() method which returns wrapper class with Data<T> as internal storage that keeps track of the start of queue.

BITARR

It is a compact array of bit values, which are represented as Booleans. It uses Data<int> as internal storage.

LFU CACHE

A data structure which uses an O(1) algorithm of implementing LFU cache eviction scheme. It has a map like API and simple cleanup methods to remove a certain number of non-relevant items from the cache. In addition to that it can keep track of cached data obsolescence by last accessed timestamp and remove those obsolete items on demand.

https://github.com/papers-we-love/papers-we-love/blob/main/caching/a-constant-algorithm-for-implementing-the-lfu-cache-eviction-scheme.pdf

Stackalloc and ref struct

There are basic collections implemented:

  • DataRs
  • MapRs
  • SetRs
  • QueueRs
  • StackRs

It turned out that overall performance of stackalloc containers are up to 10 times faster in compare to heap allocated one.

Examples of usages:

DataRs

Span<int> memory = stackalloc int[10_000];
var dataRs = new DataRs<int>(ref memory);

dataRs.Add(1);

var first = dataRs.FirstOrDefault();

Assert.AreEqual(1, first);
Assert.AreEqual(1, dataRs.Count);

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.2.0 106 2/1/2024
4.1.4 94 1/19/2024
4.1.3 72 1/19/2024
4.1.2 133 1/4/2024
4.1.1 104 1/4/2024
4.1.0 106 12/25/2023
4.0.2 102 12/19/2023
4.0.1 94 12/18/2023
4.0.0 113 9/27/2023
3.0.0 168 4/28/2023
2.1.0 234 2/18/2023
2.0.4 217 2/17/2023
2.0.3 220 2/17/2023
2.0.2 233 2/17/2023
2.0.1 225 2/17/2023
1.0.2 386 10/11/2022
1.0.1 439 2/12/2022
1.0.0 425 2/11/2022