Please sign in to comment.
Remove default concurrrency level multiplier
Today when constructing a ConcurrentDictionary without specifying a concurrency level, the level defaults to Environment.ProcessorCount multiplied by a multiplier. In my own measurements stressing writes, this multiplier has only a small effect on write throughput but a significant effect on memory consumption. I'm removing the multiplier and leaving the default at Environment.ProcessorCount. This provides a more reasonable compromise between wanting good write throughput while still respecting memory size in the common use case of lots of reads and few writes. A developer can always specify their own concurrencyLevel and capacity if they want more control over memory allocations. A benchmark that estimates the memory consumption of a Dictionary<int, string> vs a ConcurrentDictionary<int, string> with string.Empty as values... Before: ``` Items: 0 DSize: 80 CDSize: 976 Ratio: 12.2x Items: 1 DSize: 192 CDSize: 1016 Ratio: 5.29166666666667x Items: 10 DSize: 472 CDSize: 1376 Ratio: 2.91525423728814x Items: 100 DSize: 4072 CDSize: 7552 Ratio: 1.85461689587426x Items: 1000 DSize: 38772 CDSize: 67611 Ratio: 1.74380996595481x ``` After: ``` Items: 0 DSize: 80 CDSize: 544 Ratio: 6.8x Items: 1 DSize: 192 CDSize: 584 Ratio: 3.04166666666667x Items: 10 DSize: 472 CDSize: 944 Ratio: 2x Items: 100 DSize: 4072 CDSize: 5824 Ratio: 1.43025540275049x Items: 1000 DSize: 38772 CDSize: 53740 Ratio: 1.38605178995151x ```
- Loading branch information...
Showing with 1 addition and 8 deletions.