Maximizing the Performance of Java 8 Streams
summary
Case study implements grep -B with Java 8 streams, using a mapped byte buffer and a custom Spliterator plus a collecting terminal operation to compute byte offsets without mutable accumulators. Microbenchmarking uses the Java Microbenchmark Harness and NetBeans/GC logs; common pitfalls are I/O bottlenecks, GC tuning, dead‑code elimination and a ~100 µs splitting/merge overhead. Sequential streams often beat hand loops; parallel streams reach about 2.5× on a 4‑core machine when the regex work outweighs splitting and collection costs.
AI-written summary · about
chapters (8)
- 0:00Introduction to streams
- 4:31Streams and parallelism
- 11:17Hardware and performance
- 16:47Micro-benchmarking pitfalls
- 24:35System-level performance
- 33:28JVM and garbage collection
- 41:22Case study: Grep utility
- 51:00Conclusion on parallelism
related talks
01h 00mLet’s Get to the Rapids: Java 8 Stream Performance
47mWhen Greed Is Good: Understanding Java Stream Performance
47mStreams – Below the Surface
51mSecrets of top performance in Java revealed
44mI didn't know you could do that with Java Streams!
51mIf Streams Are So Great, Let’s Use Them Everywhere... Right??
46mStreams in JDK 8: The Good, the Bad, and the Ugly
51mHunting with Stream Gatherers
