Skip to content

Commit

Permalink
JPERF-1409 Fix JFR flamegraph in intellij
Browse files Browse the repository at this point in the history
Fixes 'Total time' tab that was previously unavailable
  • Loading branch information
mgrzaslewicz authored and dagguh committed Dec 6, 2023
1 parent 0f66a60 commit 73aaaed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Dropping a requirement of a major version of a dependency is a new contract.

### Fixed
- Bump async-profiler to v2.10.
- Provide a default interval for async-profiler. Workaround for [IDEA-320011]. Help fix [JPERF-1409].

[IDEA-320011]: https://youtrack.jetbrains.com/issue/IDEA-320011
[JPERF-1409]: https://ecosystem.atlassian.net/browse/JPERF-1409

## [4.28.0] - 2023-10-11
[4.28.0]: https://github.com/atlassian/infrastructure/compare/release-4.27.0...release-4.28.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.atlassian.performance.tools.jvmtasks.api.IdempotentAction
import com.atlassian.performance.tools.jvmtasks.api.StaticBackoff
import com.atlassian.performance.tools.ssh.api.SshConnection
import java.time.Duration
import java.time.Duration.ofMillis
import java.time.Duration.ofSeconds

/**
Expand Down Expand Up @@ -67,6 +68,8 @@ class AsyncProfiler private constructor(
private var outputFile: String = "flamegraph.html"
private val startParams = mutableListOf<String>()
private val stopParams = mutableListOf<String>()
private var wallClockMode: Boolean = false
private var interval: Duration = ofMillis(10)

fun outputFile(outputFile: String) = apply { this.outputFile = outputFile }

Expand All @@ -93,14 +96,12 @@ class AsyncProfiler private constructor(
fun flamegraph(outputFile: String) = output("flamegraph", outputFile)

fun wallClockMode() = apply {
startParams.add("-e")
startParams.add("wall")
wallClockMode = true
}

fun interval(interval: Duration) = apply {
startParams.add("-i")
if (interval < ofSeconds(1)) {
startParams.add(interval.nano.toString())
this.interval = interval
} else {
throw Exception("The interval $interval seems to big. Usually it's counted in milliseconds or nanoseconds. Try an interval under a second.")
}
Expand All @@ -124,9 +125,15 @@ class AsyncProfiler private constructor(
}

fun build(): Profiler {
val startParamsCopy = startParams + "-o $outputFormat -f $outputFile"
val stopParamsCopy = stopParams + "-o $outputFormat -f $outputFile"
val startParamsCopy = (
startParams
+ (if (wallClockMode) "-e wall" else null)
+ "-i ${interval.nano}"
+ "-o $outputFormat"
+ "-f $outputFile"
).filterNotNull()
val stopParamsCopy = stopParams + "-o $outputFormat -f $outputFile"
return AsyncProfiler(startParamsCopy, stopParamsCopy, outputFile)
}
}
}
}

0 comments on commit 73aaaed

Please sign in to comment.