-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Make ToDictionary() selectors parallel. #100590
base: main
Are you sure you want to change the base?
Make ToDictionary() selectors parallel. #100590
Conversation
As stated in #96262 (comment), this will likely regress cases with a trivial key selector. @lateapexearlyspeed could you please provide a benchmark to see how bad it hits it so we can do an informed decision? |
@jozkee following is benchmark result of trivial key (and element) selector case. Toolchain in "runtime-main" is library before change and toolchain in "runtime" is library after change. // * Summary * BenchmarkDotNet=v0.13.1.1603-nightly, OS=Windows 10.0.22631 PowerPlanMode=00000000-0000-0000-0000-000000000000 Arguments=/p:DebugType=portable,-bl:benchmarkdotnet.binlog IterationTime=250.0000 ms
[Benchmark]
public void TestParallelToDictionary()
{
IEnumerable<int> collection = Enumerable.Range(0, ItemCount);
Dictionary<int, int> _ = collection.AsParallel().ToDictionary(i => i, i => i);
}
[Params(1, 10, 100, 1000, 10000)]
public int ItemCount { get; set; } |
@EgorBot -amd using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<Tests>(args: args);
public class Tests
{
[Benchmark]
public void TestParallelToDictionary()
{
IEnumerable<int> collection = Enumerable.Range(0, ItemCount);
Dictionary<int, int> _ = collection.AsParallel().ToDictionary(i => i, i => i);
}
[Benchmark]
public void TestSelectParallelToDictionary()
{
IEnumerable<int> collection = Enumerable.Range(0, ItemCount);
Dictionary<int, int> _ = collection.AsParallel().Select(i => i).ToDictionary(i => i, i => i);
}
[Benchmark]
public void TestWhereSelectParallelToDictionary()
{
IEnumerable<int> collection = Enumerable.Range(0, ItemCount);
Dictionary<int, int> _ = collection.AsParallel().Where(i => true).Select(i => i).ToDictionary(i => i, i => i);
}
[Params(1, 10, 100, 1000, 10000)]
public int ItemCount { get; set; }
} |
@EgorBo, what's the invocation syntax for your bot? |
I typically use Example: #102805 (comment)
|
@EgorBot -intel -arm64
|
Thanks. What am I doing wrong that it's not kicking in? |
It's correct as is (I already see 3 16-core VMs allocated for these requests😆) - it's just that currently there is no feedback that the jobs have started yet |
Ah! Ok. I'm used to the other bots that post a comment indicating that they've received the request. Thanks. |
|
|
It looks like @EgorBo's test results show some significant regressions. Am I reading that correctly @jozkee @stephentoub? |
Yes |
Fix #96262