I'm running CreditRiskExample on 11 nodes cluster (16 Gb RAM, core i7, 1 Tb each node). I'm using parallel stream of Java 8. Why parralel version which uses Java 8 lambdas (Code B) is slower then not parallel version (Code A)?
Code A (Credit risk [crdRisk=627147.908398507, duration=73667ms]):
double losses = new double[num];
for (int i = 0; i < num; i++)
for (Credit crd : portfolio)
int remDays = Math.min(crd.getRemainingTerm(), horizon);
Ignite already runs all jobs in parallel and utilizes CPU cores to the maximum. In this case, adding more concurrency will only slow you down, because tasks start competing for CPU cores against each other.
The list may not be large enough to get advantage of the parallel processing.
I am tempted to think that the slow down is caused by the first (1) point.
I think what you can do is check in Task Monitor (Win) or Activity Monitor (Mac) if all the cores are utilized by Ignite jobs during the execution. If so, then adding additional threads to execute the list in parallel will only slow you down.
As I suggested before, I believe Ignite already utilizes all the Cores, so if you try to do something additional in parallel, you are essentially beginning to compete with Ignite jobs.
To check that, look at your Core utilization when you are NOT using parallel streams and see if all the cores are utilized by Ignite. If yes, then parallel streams will only slow it down because they will add thread contention.