Skip to content

Commit beec0d0

Browse files
committed
Update
1 parent 9f23c18 commit beec0d0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/scala/sample/stream/FlightDelayStreaming.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ import scala.util.{Failure, Success, Try}
3333
*
3434
* Typical results on 2012 vintage MacBook Pro with 8 cores
3535
* with default dispatcher and default JVM param:
36-
* JDK 11.0.11 41 seconds
37-
* JDK 17.0.2 33 seconds
38-
* JDK 21.0.3 27 seconds
39-
* graalvm-jdk-21 25 seconds
36+
* temurin-11 31 seconds
37+
* temurin-21 21 seconds
38+
* graalvm-jdk-21 18 seconds
4039
*
4140
* Doc:
4241
* https://fullgc.github.io/how-to-tune-akka-to-get-the-most-from-your-actor-based-system-part-1
@@ -48,7 +47,7 @@ object FlightDelayStreaming extends App {
4847

4948
import system.dispatcher
5049

51-
val sourceOfLines = FileIO.fromPath(Paths.get("src/main/resources/2008.csv"))
50+
val sourceOfLines = FileIO.fromPath(Paths.get("src/main/resources/2008_subset.csv"))
5251
.via(Framing.delimiter(ByteString(System.lineSeparator), maximumFrameLength = 1024, allowTruncation = true)
5352
.map(_.utf8String))
5453

@@ -66,15 +65,15 @@ object FlightDelayStreaming extends App {
6665
val filterAndConvert: Flow[FlightEvent, FlightDelayRecord, NotUsed] =
6766
Flow[FlightEvent]
6867
.filter(r => Try(r.arrDelayMins.toInt).getOrElse(-1) > 0) // convert arrival delays to ints, filter out non delays
69-
.mapAsyncUnordered(parallelism = 2) { r =>
68+
.mapAsyncUnordered(parallelism = 100_000) { r =>
7069
Future(FlightDelayRecord(r.year, r.month, r.dayOfMonth, r.flightNum, r.uniqueCarrier, r.arrDelayMins))
7170
}
7271

7372
// Aggregate number of delays and totalMins
7473
val averageCarrierDelay: Flow[FlightDelayRecord, FlightDelayAggregate, NotUsed] =
7574
Flow[FlightDelayRecord]
7675
// maxSubstreams must be larger than the number of UniqueCarrier in the file
77-
.groupBy(30, _.uniqueCarrier, allowClosedSubstreamRecreation = true)
76+
.groupBy(100, _.uniqueCarrier, allowClosedSubstreamRecreation = true)
7877
//.wireTap(each => println(s"Processing FlightDelayRecord: $each"))
7978
.fold(FlightDelayAggregate("", 0, 0)) {
8079
(x: FlightDelayAggregate, y: FlightDelayRecord) =>

0 commit comments

Comments
 (0)