Java Parallel Streams Internals: Demo'ing Collector Performance (Part 3)

preview_player
Показать описание
This video explores the performance of concurrent and non-concurrent collectors in Java when dealing with sequential and parallel streams. I show the results or running the ex36 driver program to compute benchmarks with different numbers of words from Shakespeare's works to gauge the efficiency and scalability of concurrent and non-concurrent collectors for sequential and parallel streams. The results show that for small datasets, sequential streams outperform their parallel counterparts. However, as the data size increases, especially around ~910,000 words, parallel concurrent collectors become significantly more efficient. I also contrast the performance of hash sets and tree sets, finding that tree sets perform exceptionally well with parallel concurrent collectors for large datasets. Lastly, I walk through the internals of a custom ConcurrentSetCollector that is optimized for different types of Java Set implementations, including HashSet and TreeSet.
Рекомендации по теме
Комментарии
Автор

Hi Professor,

I didn't understand why you have written this comment in ConcurrentSetCollector class on combiner functions.
"This method isn't really necessary when a parallel stream is used! However, we also use it with a sequential stream, so we need to provide an implementation here."

If, we are using Concurrent Collector, we don't need to use combiner even in case of ||el execution whereas in case of sequential execution, combiner is actually not needed whether it is concurrent collectors or non-concurrent collectors, only in case of ||el execution and non-concurrent collectors, combiner function is used.

So, I just want to know why you written "However, we also use it with a sequential stream, so we need to provide an implementation here." ? Do you mean it will be executed in sequential execution.

Rohit-hswp