Skip to content

Commit

Permalink
Qualification tool: fix performance regression (#2974)
Browse files Browse the repository at this point in the history
* Change event process loop to be find instead of while which is slow

Signed-off-by: Thomas Graves <tgraves@nvidia.com>

* cleanup
  • Loading branch information
tgravescs authored Jul 20, 2021
1 parent 173a822 commit f6fa050
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@ abstract class AppBase(
logFiles.foreach { file =>
Utils.tryWithResource(openEventLogInternal(file.getPath, fs)) { in =>
val lines = Source.fromInputStream(in)(Codec.UTF8).getLines().toList
var i = 0
var done = false
val linesSize = lines.size
while (i < linesSize && !done) {
try {
val line = lines(i)
// Using find as foreach with conditional to exit early if we are done.
// Do NOT use a while loop as it is much much slower.
lines.find { line =>
val isDone = try {
totalNumEvents += 1
val event = JsonProtocol.sparkEventFromJson(parse(line))
done = processEvent(event)
processEvent(event)
}
catch {
case e: ClassNotFoundException =>
Expand All @@ -102,8 +100,9 @@ abstract class AppBase(
if (!e.getMessage.contains("SparkListenerResourceProfileAdded")) {
logWarning(s"ClassNotFoundException: ${e.getMessage}")
}
false
}
i += 1
isDone
}
}
}
Expand Down

0 comments on commit f6fa050

Please sign in to comment.