Comments (4)
@dzmitry-lahoda Pooled dictionary is marginally slower for some operations. The main performance benefit is when adding many elements to a dictionary that did not have its capacity explicitly set. In that scenario, adding can be as much as 40-50% faster.
The other benefit of PooledDictionary is memory allocations. This doesn't relate directly to the performance of any specific operation, but if you're creating and destroying many instances of the same type of dictionary, or adding a very large number of items to dictionaries, PooledDictionary gives you far less memory allocated, resulting in fewer GC pauses and memory spikes. This is in my opinion the primary motivation one would have to use PooledDictionary over Dictionary.
If you have any specific suggestions on how to speed up the PooledDictionary operations that are slower than the equivalent Dictionary operations, I would welcome a pull request. I've gotten the performance as close as I can, for the moment, figure out how to.
There's similar issues in PooledList: the indexer-get operation is 9-10 times slower than that of List, despite being the exact same code, as far as I can tell! I haven't found any way of closing that gap other than removing the bounds-check, which isn't a good idea. I suspect some sort of List-specific optimization in the framework that PooledList can't benefit from. However, indexing into PooledList.Span is 84% faster than indexing into List, so there's that.
Right now I'm focused mainly on finishing a few more of the collections I want to convert (Stack, Hashset) because I need to use them, but I would welcome feedback on what sort of documentation you're hoping to see for this sort of thing.
from collections.pooled.
When I do approach libraries what I want to see it that why should I use it. I used first hand Pooled list because it does saves some GC and has Span view (good for networked games). So, the text you have written in reply is kind of 50% of documentation which could-should probably in readme. It will allow any developer to evaluate use vs not without digging into details. So it is possibly close issues or convert, what may be considered stable and important to part of readme.
from collections.pooled.
Seems I have found root cause of #8 . Could you point me to some cases when PooledDictionary is slower?
from collections.pooled.
The GetItem benchmark could stand to be better. It's a very common use-case, and it's about 20-30% slower in PooledDictionary. I'm hopeful that your ThrowHelper find will also improve this case.
Benchmark code:
https://github.com/jtmueller/Collections.Pooled/blob/master/Collections.Pooled.Benchmarks/PooledDictionary/Dict.GetItem.cs
from collections.pooled.
Related Issues (20)
- new PooledList<PlayerState>(Players.Count, preallocate : true) HOT 8
- PooledList.Dispose semantics HOT 6
- Support for .NET Standard 2.1 HOT 15
- Disposing PooledDictionary doesn't dispose PooledList stored as values HOT 2
- Support for ObservableCollection HOT 6
- GC of boxing if key is struct HOT 1
- Aggressive optimization and inlining foor PooledList.Span HOT 5
- Retrieve Memory<T> from PooledList<T>
- Nested pooled collections crash the Visual Studio heap snapshot
- Resurrect rented buffers or arrays in finalyzer HOT 1
- Pooled Lookup
- Pooled Array
- PooledSet is generating GC when item gets removed HOT 1
- Add equivalent of CollectionsMarshal.GetValueRef for PooledDictionary.
- Why not implents INotifyCollectionChanged or provide a BindingVersion
- linq benefits from pooled? HOT 1
- Consider PooledSortedList
- Is the repos alive?
- How about call GC.SuppressFinalize(this) to prevent add to finalization queue.
- PooledDictionary.Remove with Count 0 = Exception HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from collections.pooled.