Option to enable parallelism? #652
Ackermannen
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Noticed that initial compilation took a long time. My use case for the library is within blazor, so loading times are important for the overall experience. Are there dangers in running the compilation in parallel?
Parallel.ForEach(workflow.Rules.Where(c => c.Enabled), new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, rule => { var compiledRule = CompileRule(rule, workflow.RuleExpressionType, ruleParams, globalParamExp); dictFunc.TryAdd(rule.RuleName, compiledRule); });
Parallel.ForEach(compiledRules, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, compiledRule => { var resultTree = compiledRule(ruleParameters); result.Add(resultTree); });
From my use case, i am not getting any adverse effects except the ordering of course. Note that i switched out the Dictionary with ConcurrentDictionary and List with ConcurrentBag
Beta Was this translation helpful? Give feedback.
All reactions