Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiling tool : Profiling tool throws NPE when appInfo is null and unchecked #640

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -388,11 +388,12 @@ class Analysis(apps: Seq[ApplicationInfo]) {
val allRows = apps.flatMap { app =>
app.sqlIdToInfo.map { case (sqlId, sqlCase) =>
SQLDurationExecutorTimeProfileResult(app.index, app.appId, sqlId, sqlCase.duration,
sqlCase.hasDatasetOrRDD, app.appInfo.duration, sqlCase.problematic,
sqlCase.hasDatasetOrRDD,
Option(app.appInfo).flatMap(_.duration).orElse(Option(0L)),
sqlCase.problematic,
sqlCase.sqlCpuTimePercent)
}
}

if (allRows.size > 0) {
val sortedRows = allRows.sortBy { cols =>
val sortDur = cols.duration.getOrElse(0L)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,25 +34,25 @@ case class StageMetrics(numTasks: Int, duration: String)
class CollectInformation(apps: Seq[ApplicationInfo]) extends Logging {

def getAppInfo: Seq[AppInfoProfileResults] = {
val allRows = apps.map { app =>
val a = app.appInfo
val allRows = apps.collect {
case app if app.appInfo != null => val a = app.appInfo
AppInfoProfileResults(app.index, a.appName, a.appId,
a.sparkUser, a.startTime, a.endTime, a.duration,
a.durationStr, a.sparkVersion, a.pluginEnabled)
}
if (allRows.size > 0) {
if (allRows.nonEmpty) {
allRows.sortBy(cols => (cols.appIndex))
} else {
Seq.empty
}
}

def getAppLogPath: Seq[AppLogPathProfileResults] = {
val allRows = apps.map { app =>
val a = app.appInfo
val allRows = apps.collect {
case app if app.appInfo != null => val a = app.appInfo
AppLogPathProfileResults(app.index, a.appName, a.appId, app.eventLogPath)
}
if (allRows.size > 0) {
if (allRows.nonEmpty) {
allRows.sortBy(cols => (cols.appIndex))
} else {
Seq.empty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -138,4 +138,17 @@ class AnalysisSuite extends FunSuite {
val containsDs = sqlDurAndCpu.filter(_.containsDataset === true)
assert(containsDs.size == 1)
}

test("test duration for null appInfo") {
val qualLogDir = ToolTestUtils.getTestResourcePath("spark-events-qualification")
val logs = Array(s"$qualLogDir/dataset_eventlog")

val apps = ToolTestUtils.processProfileApps(logs, sparkSession)
apps.foreach { app =>
app.appInfo = null
}
val analysis = new Analysis(apps)
val metrics = analysis.sqlMetricsAggregationDurationAndCpuTime()
metrics.foreach(m => assert(m.appDuration.get == 0L))
}
}
Loading