We need to execute some calculations where the inputs are the outputs of other calculations. This can be modelled as a tree like below:
Here is the expected behavior, calculation jobs 1 through 6 are scheduled first. When 1, 2, and 3 are done then 7 is scheduled. When 4 is done then 8 is scheduled. When 5 and 6 are done then 9 will be scheduled. 10 will only be scheduled when 7, 8, and 9 are done. 11 waits for 10 and 12 waits for 11.
How would we batch these using the api in hangfire pro?
We are contemplating buying the pro license but we need to confirm it will cover the above use case.
Related
This question already has answers here:
Parallel tasks performance in c#
(2 answers)
Closed 1 year ago.
I sent over than 100 requests to web service I am using Parallel.Foreach and it handle it well, but when see the traffic using Wireshark I only see 4 or up to 10 requests per second.
Then I tried the same case on same machine in SOAPUI TOOL in bulk multi threading
Mode then I saw that the 100 requests are sent in same second.
Any advice nothing that I am using
C# 2017
Framework 4.5
OS win 10
CPU cores 4 I7
RAM 16 GB
This is not a parallel.foreach issue - the issue is ServicePointManager which throttles the number of parallel requests to any domain name. The standard is, as you found out, 4 parallel requests.
https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager?view=net-5.0
Parallel.ForEach will quue all the tasks, but then the requests run into the limitation. Oh, and that manager can be configured ;)
One of the .Net Core versions (I'm not sure which) introduced an optimisation such that if you write code like this:
int smallest = new[]{ 7, 2, 4, 6, 0, 1, 6, 9, 8 }.OrderBy(i => i).First();
then its complexity is O(N) rather than O(N.Log(N)).
Is this documented anywhere? I don't want to rely on this optimisation if it isn't "official".
Sample code that shows the difference between .Net Core and .Net Framework:
using System;
using System.Collections.Generic;
using System.Linq;
namespace Demo
{
static class Program
{
static void Main()
{
int[] test = { 7, 2, 4, 6, 0, 1, 6, 9, 8 };
var comparer = new Comparer();
var _ = test.OrderBy(i => i, comparer).First();
}
}
class Comparer : IComparer<int>
{
public int Compare(int x, int y)
{
Console.WriteLine($"Comparing {x} with {y}");
return x.CompareTo(y);
}
}
}
Try it online with .Net Framework: https://dotnetfiddle.net/XItXYL
Try it online with .Net Core: https://dotnetfiddle.net/swlc0O
Output with .Net Framework 4.8:
Comparing 0 with 7
Comparing 0 with 8
Comparing 0 with 9
Comparing 0 with 6
Comparing 0 with 1
Comparing 0 with 0
Comparing 0 with 2
Comparing 0 with 6
Comparing 0 with 4
Comparing 0 with 2
Comparing 0 with 0
Comparing 7 with 2
Comparing 7 with 4
Comparing 7 with 6
Comparing 7 with 7
Comparing 7 with 8
Comparing 7 with 9
Comparing 7 with 6
Comparing 7 with 1
Comparing 7 with 7
Comparing 7 with 1
Comparing 9 with 7
Comparing 9 with 9
Comparing 9 with 8
Comparing 7 with 7
Comparing 7 with 8
Comparing 7 with 7
Comparing 6 with 2
Comparing 6 with 4
Comparing 6 with 6
Comparing 6 with 1
Comparing 6 with 6
Comparing 6 with 6
Comparing 6 with 1
Comparing 6 with 6
Comparing 6 with 6
Comparing 4 with 2
Comparing 4 with 4
Comparing 4 with 1
Comparing 2 with 2
Comparing 2 with 1
Output for .Net Core 3.1:
Comparing 2 with 7
Comparing 4 with 2
Comparing 6 with 2
Comparing 0 with 2
Comparing 1 with 0
Comparing 6 with 0
Comparing 9 with 0
Comparing 8 with 0
The answer to the question "Is this optimisation documented" is: Yes (kind-of).
See https://github.com/dotnet/runtime/issues/14867 for the discussion and links to the GitHub commits that implement it.
This isn't officially documented in the Microsoft documentation on those LINQ operators (OrderBy and First).
This is intentional. Once a behavior is officially documented this way, any change to that behavior becomes a breaking change, which may limit the developers' ability to make other optimizations which may be even more beneficial. If you are going to rely on specific implementation details, you should probably write your own method for this purpose.
That said, it's relatively rare for the O(n) versus O(n log(n)) complexity to make the difference between acceptable and unacceptable performance in an application. Consider carefully whether you're engaging in premature optimization.
Can someone please confirm or correct my understanding of the order of values when using Value.CreateBatch instead of MinibatchSource?
Assuming the CTF equivalent is:
|x 1 2 3
|x 4 5 6
|x 7 8 9
Would a batch of size 3 become (a) 1 2 3 4 5 6 7 8 9 or (b) 1 4 7 2 5 8 3 6 9?
My current perception is (a) however I'd greatly appreciate this being confirmed or corrected. Many thanks in advance.
Of course, a) is the correct answer. In each line x is the name of the input data followed by the input data itself.
It is implicated in this tutorial for CNTK: https://cntk.ai/pythondocs/CNTK_103C_MNIST_MultiLayerPerceptron.html#Data-reading
and I also can tell it from my experience.
I have a workflow (WF 4.5) which is basically a series of questions. However, I need to be able to persist this workflow so that the user can resume at the last question he answered, or at any question before that one, so that he can change his answers.
For example, if the workflow has a total of 10 questions (question 1 to 10), and the user answered them up to question number 7, I want him to be able to choose which question he wants to resume up to question 7, which would allow him to choose any question from 1 to 7. If he chooses question 3, he will be able to give a new answer to question 3, 4, 5, 6, 7 and continue up to question 10.
Is it possible to accomplish that through bookmarks? Could I create a different bookmark for each question, and even if the user is already at question 7 (with 7 bookmarks created up to this point), can I resume the workflow from the bookmark created at question 3, for example? If not, how can this be accomplished?
I am not sure I got your Question correctly
but if you wanna go back to the any steps of the workflow you can do it by return to book Mark
and you can add book mark in each step in your workflow
actually in every step you waiting dta from user you will need a book mark so you can return where it's stopped
wish the answer help you
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How Can I Set Processor Affinity in .NET?
I have i7 930x . my computer have cpu 4core.And 8 processor(thread 8)
so.. processor 1 , 2 ,3 ,4 .... 8.
but i want only number 1 processor. i don't want using other phsycal.
c# is possible?
example) my calc program using cpu No1.
my sound program using cpu No2.<br>
my Network A Program using cpu No1.<br>
my Network B Program using cpu No3.<br>
It is possible to set a processor affinity mask for threads/processes to accomplish that. For some high performance programs using thread pools and work queues it can improve performance. In all other cases it is better to let the OS handle the scheduling.