问题标签 [plinq]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - PLINQ 聚合异常我不明白
我正在观看 Igor Ostrovsky 的 PLINQ PCD09 演示,想看看我能从我的 CULV 笔记本电脑中得到什么。
有一次我遇到了一个奇怪的例外,我不确定这意味着什么。我已经压缩了代码以获得更好的概述。这是导致异常的最后一个 primes.Sum() ,如果我将范围缩小 - 8000 - 则不会引发异常。有任何想法吗?
异常(很长)
System.AggregateException 未处理 Message=发生一个或多个错误。Source=System.Core
StackTrace:在 System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose) 在 System.Linq.Parallel.SpoolingTask.SpoolStopAndGo[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream2 partitions, SynchronousChannel
1[] channels, TaskScheduler taskScheduler) 在System.Linq.Parallel.DefaultMergeHelper2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute() at System.Linq.Parallel.MergeExecutor
1.Execute[TKey](PartitionedStream2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId) at System.Linq.Parallel.PartitionedStreamMerger
1.Receive[TKey](PartitionedStream2 partitionedStream) at System.Linq.Parallel.InlinedAggregationOperator
3.WrapPartitionedStream[TKey](PartitionedStream2 inputStream, IPartitionedStreamRecipient
1 接收者,布尔值 preferStriping,QuerySettings 设置) 在 System.Linq.Parallel.UnaryQueryOperator2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream
2 inputStream ) 在 System.Linq.Parallel.WhereQueryOperator1.WrapPartitionedStream[TKey](PartitionedStream
2 inputStream, IPartitionedStreamRecipient1 recipient, Boolean preferStriping, QuerySettings settings) at System.Linq.Parallel.UnaryQueryOperator
2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream2 inputStream) at System.Linq.Parallel.ScanQueryOperator
1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) at System.Linq.Parallel.UnaryQueryOperator
2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) at System.Linq.Parallel.UnaryQueryOperator
2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient1 recipient) at System.Linq.Parallel.QueryOperator
1.GetOpenedQuery1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings) at System.Linq.Parallel.QueryOpeningEnumerator
()) Linq.Parallel.QueryOpeningEnumerator1.MoveNext() at System.Linq.Parallel.IntSumAggregationOperator.InternalAggregate(Exception& singularExceptionToThrow) at System.Linq.Parallel.InlinedAggregationOperator
3.Aggregate() 在 System.Linq.ParallelEnumerable.Sum(ParallelQuery1 source) at ConsoleTest.TestClass.Test() in C:\Users\henrik\Documents\Visual Studio 2010\Projects\CSharp\ConsoleTest\ConsoleTest\TestClass.cs:line 23 at ConsoleTest.Program.Main(String[] args) in C:\Users\henrik\Documents\Visual Studio 2010\Projects\CSharp\ConsoleTest\ConsoleTest\Program.cs:line 20 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.OverflowException Message=Arithmetic operation resulted in an overflow. Source=System.Core StackTrace: at System.Linq.Parallel.IntSumAggregationOperator.IntSumAggregationOperatorEnumerator
1.MoveNextCore(Int32& currentElement) 在 System.Linq.Parallel.InlinedAggregationOperatorEnumerator1.MoveNext(TIntermediate& currentElement, Int32& currentKey) at System.Linq.Parallel.StopAndGoSpoolingTask
2.SpoolingWork() 在 System.Linq.Parallel.SpoolingTaskBase.Work() 在 System.Linq.Parallel.QueryTask.BaseWork(对象未使用) 在 System.Linq.Parallel.QueryTask.<.cctor>b__0(Object o) 在System.Threading.Tasks.Task.InnerInvoke() 在 System.Threading.Tasks.Task.Execute() InnerException:
.net-4.0 - IEnumerable 收益回报与 .AsParallel() 相结合
我写了一些代码来尝试描述我的担忧:
GetClassMarks 使用来自我奇怪的数据源的收益返回。假设 GenerateClassReport 基本上是用 mark.Sum()/marks.Count() 来获得班级平均值。
据我了解,students.AsParallel().ForAll 是一个并行的 foreach。
我担心的是 GetClassMarks 方法内部会发生什么。
- 它会被枚举一次还是多次?
- 枚举将以什么顺序发生?
- 我是否需要在标记上执行 .ToList() 以确保它只被击中一次?
c# - 通过反射同时设置多个属性
我正在尝试优化代码中的反射利用率,我想知道是否可以一次设置对象的多个属性:
示例用法:
在哪里
我希望将 SetProps 扩展方法替换为更有效的方法,但还没有找到合适的方法。提前致谢 ;)
我已经使用评论中提供的链接修改了代码。常规方式仍然快 4 倍。问题是这是极限还是还有改进的余地?
c# - 在 PLINQ 中取消长时间运行的任务
我正在尝试使用 NET 4.0 并行任务库来处理多个 FTS 查询。如果查询花费了太多时间,我想取消它并继续处理其余的。
当一个查询超过阈值时,此代码不会停止。我想我这样称呼它是为了整个过程而不是单个事务达到取消任务和时间限制。如果我将时间段设置得非常小(300 毫秒),那么所有搜索字符串都会调用它。
我想我错过了一些明显的东西..提前感谢您的任何见解。
此外,这似乎仍然无法阻止非常长的查询执行。这甚至是在触发长时间运行的查询后取消它的正确方法吗?
修改后的代码:
c# - 可以使用 plinq ForAll 批量插入数据库吗?
我正在这样做:
这很好吗,我会有更多的表现吗?
c# - PLINQ 的性能比通常的 LINQ 差
令人惊讶的是,使用 PLINQ 并没有对我创建的一个小测试用例产生任何好处。事实上,它甚至比通常的 LINQ 还要糟糕。
这是测试代码:
结果?
所以,LINQ 比 PLINQ 花费更少的时间来完成类似的操作!
我究竟做错了什么?还是有我不知道的转折?
编辑:我已经更新了我的代码以使用秒表,但同样的行为仍然存在。为了降低 JIT 的影响,我实际上尝试了几次同时单击button1
,button2
并且没有特定的顺序。虽然我得到的时间可能不同,但定性行为仍然存在:PLINQ 在这种情况下确实比较慢。
c# - 使用 Let 并行化 LINQ 查询,选择关键字
我有以下 LINQ 查询
from
until将into meshPlan
选择一个meshPlan
s 列表。这是我相信并行化可以利用的部分。
关于如何使用 PLINQ 并行化上述操作的任何想法?
我尝试了以下操作:
但遗憾的是它无法编译。
.net - PLINQ 更新失败
对不起我的英语不好。所以,这是我的问题,我正在尝试通过 PLINQ 更新 DataTable 这是我的代码
但有例外:“索引超出范围。必须为非负数且小于集合的大小。参数名称:索引”
请帮我
plinq - 编译器能否自动并行化支持并行化的代码?
除了手动添加 Plinq 扩展语句 AsParallel() 之外,编译器不能自动为我们解决这个问题吗?如果代码支持,是否有任何您特别不希望并行化的示例?
.net-4.0 - 嵌套并行查询
运行嵌套的 PLINQ 查询是否有任何问题?
例如: