I try use PPL and ITask, but I get strange things.
I try use PPL and ITask, but I get strange things.
Example code (console, mini app):
https://pastebin.com/aLGYwZfB
Results:
First Test 1 thread - Loop count: 1000000, time: 3447 ms
Second Test 4 thread - Loop count: 1000000, time: 13232 ms
But when I run only second test (without first) I get:
Second Test 4 thread - Loop count: 1000000, time: 4531 ms
13323 vs 4531 ms, why??
Delphi Tokyo
https://pastebin.com/aLGYwZfB
Example code (console, mini app):
https://pastebin.com/aLGYwZfB
Results:
First Test 1 thread - Loop count: 1000000, time: 3447 ms
Second Test 4 thread - Loop count: 1000000, time: 13232 ms
But when I run only second test (without first) I get:
Second Test 4 thread - Loop count: 1000000, time: 4531 ms
13323 vs 4531 ms, why??
Delphi Tokyo
https://pastebin.com/aLGYwZfB
I certainly agree with that!!!
ReplyDeleteDarian Miller Proper analysis. Inside of TQueueWorkerThread.Execute it takes a few instructions between the fetching of the item from the workqueue up to the point where it decreases the FIdleWorkerThreadCount. So the loop over the lThreads[j].Start; runs faster than that and all items get pushed into the workqueue without a second worker thread to be created.
ReplyDeleteDid anyone report that yet?
Stefan Glienke Thanks for also analysing this. I don't think that anybody reported it yet at least not using the keyword PPL as far as I can tell- but it would not be the first time I oversaw already existing reports.
ReplyDelete