|
|
Home » Developing U++ » UppHub » Job package: A lightweight worker thread for non-blocking operations. (A)
Re: RE: Job package: A scope-bound worker thread for non-blocking operations. [message #48788 is a reply to message #48782] |
Tue, 19 September 2017 08:12 |
Oblivion
Messages: 1094 Registered: August 2007
|
Senior Contributor |
|
|
Hello Mirek,
(Thank you for your comments. I deeply appreciate it.)
I was curious about if the new design of Job class will pay off, whether it is also a resonable general paralellization tool, and did some benchmarking with the Divisors example.
I assumed Job and CoWork to be functionally and effectively identical in this example (In the sense that, regardless of their internals, they are both doing the same thing: Calculating divisiors for the number 1000, 10.000 times in available worker threads, then printing the results to the screen.)
I simply changed the jobs loop to take advantage of new return semantics (I don't know if CoWork can be put into a similar loop, so I am taking this with a grain of salt):
The loop for the job is simply a very crude slot manager for 8 Job workers. (Tested on AMD FX 6100, six core processor.)
Array<Job<String>> jobs;
jobs.SetCount(CPU_Cores() + 2);
CoWork cowork;
// cowork.SetPoolSize(CPU_Cores() + 2);
Vector<String> results;
DUMP(CPU_Cores());
{
TIMING("CoWork -- With stdout output");
for(int i = 0; i < 10000; i++)
cowork & [=, &results] { String h = GetDivisors(); CoWork::FinLock(); results.At(i) = h; };
cowork.Finish();
// Stdout output section.
for(auto& r : results)
Cout() << r << '\n';
}
{
TIMING("Job -- With stdout output");
int i = 0;
while(i < 10000) {
for(auto& job : jobs) {
if(!job.IsFinished()) {
continue;
}
job & [=]{ Job<String>::Data() = GetDivisors(); };
if(!(~job).IsEmpty()) {
Cout() << ~job << '\n';
if(++i == 10000) break;
}
}
}
}
Results (consistent):
For 10000 computiation.
CPU_Cores() = 6
TIMING Job -- With stdout output: 370.00 ms - 370.00 ms (370.00 ms / 1 ), min: 370.00 ms, max: 370.00 ms, nesting: 1 - 1
TIMING CoWork -- With stdout output: 461.00 ms - 461.00 ms (461.00 ms / 1 ), min: 461.00 ms, max: 461.00 ms, nesting: 1 - 1
CPU_Cores() = 6
TIMING Job -- Without stdout output: 228.00 ms - 228.00 ms (228.00 ms / 1 ), min: 228.00 ms, max: 228.00 ms, nesting: 1 - 1
TIMING CoWork -- Without stdout output: 234.00 ms - 234.00 ms (234.00 ms / 1 ), min: 234.00 ms, max: 234.00 ms, nesting: 1 - 1
for 1000 compuitation.
CPU_Cores() = 6
TIMING Job -- With stdout output: 34.00 ms - 34.00 ms (34.00 ms / 1 ), min: 34.00 ms, max: 34.00 ms, nesting: 1 - 1
TIMING CoWork -- With stdout output: 53.00 ms - 53.00 ms (53.00 ms / 1 ), min: 53.00 ms, max: 53.00 ms, nesting: 1 - 1
CPU_Cores() = 6
TIMING Job -- Without stdout output: 24.00 ms - 24.00 ms (24.00 ms / 1 ), min: 24.00 ms, max: 24.00 ms, nesting: 1 - 1
TIMING CoWork -- Without stdout output: 31.00 ms - 31.00 ms (31.00 ms / 1 ), min: 31.00 ms, max: 31.00 ms, nesting: 1 - 1
What do you think?
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Tue, 19 September 2017 09:51] Report message to a moderator
|
|
|
|
|
Job package: A lightweight worker thread for non-blocking operations.
By: Oblivion on Sun, 10 September 2017 12:29
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: mirek on Sun, 10 September 2017 15:08
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: mirek on Sun, 10 September 2017 15:56
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: Oblivion on Sun, 10 September 2017 17:05
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: Oblivion on Sun, 10 September 2017 19:08
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: mirek on Sun, 10 September 2017 20:13
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: Oblivion on Sun, 10 September 2017 21:16
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: mirek on Mon, 11 September 2017 00:06
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: Oblivion on Mon, 11 September 2017 00:25
|
|
|
RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Sun, 17 September 2017 23:20
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Mon, 18 September 2017 08:23
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Mon, 18 September 2017 08:29
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 19 September 2017 00:01
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 19 September 2017 08:37
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 19 September 2017 08:53
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 19 September 2017 10:12
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 19 September 2017 08:12
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 19 September 2017 10:15
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 19 September 2017 10:24
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 19 September 2017 11:12
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 19 September 2017 12:31
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 19 September 2017 13:01
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Sat, 23 September 2017 14:17
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Sat, 07 October 2017 15:03
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Sat, 07 October 2017 15:51
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Sat, 07 October 2017 16:04
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Sun, 08 October 2017 15:01
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 10 October 2017 11:51
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 10 October 2017 16:10
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 10 October 2017 17:02
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Tue, 10 October 2017 20:51
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Tue, 10 October 2017 23:48
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Wed, 11 October 2017 09:23
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Wed, 11 October 2017 09:42
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Wed, 11 October 2017 09:47
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Wed, 11 October 2017 09:50
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: mirek on Wed, 11 October 2017 19:30
|
|
|
Re: RE: Job package: A scope-bound worker thread for non-blocking operations.
By: Oblivion on Wed, 11 October 2017 20:14
|
|
|
Re: Job package: A lightweight multithreading tool, using promise/future mechanism
By: mirek on Sun, 10 September 2017 20:09
|
Goto Forum:
Current Time: Wed May 29 12:05:34 CEST 2024
Total time taken to generate the page: 0.06905 seconds
|
|
|