-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 7 additions & 31 deletions
38
...n/kotlin/com/atlassian/performance/tools/infrastructure/api/profiler/WallClockProfiler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,13 @@ | ||
package com.atlassian.performance.tools.infrastructure.api.profiler | ||
|
||
import com.atlassian.performance.tools.infrastructure.api.process.RemoteMonitoringProcess | ||
import com.atlassian.performance.tools.ssh.api.SshConnection | ||
import java.time.Duration | ||
|
||
/** | ||
* A profiler to sample all threads equally every given period of time regardless of thread status. | ||
*/ | ||
class WallClockProfiler : Profiler { | ||
override fun install(ssh: SshConnection) { | ||
ssh.execute("wget -q https://github.com/jvm-profiling-tools/async-profiler/releases/download/v1.5/async-profiler-1.5-linux-x64.tar.gz") | ||
ssh.execute("mkdir async-profiler") | ||
ssh.execute("tar -xzf async-profiler-1.5-linux-x64.tar.gz -C async-profiler") | ||
ssh.execute("sudo sh -c 'echo 1 > /proc/sys/kernel/perf_event_paranoid'") | ||
ssh.execute("sudo sh -c 'echo 0 > /proc/sys/kernel/kptr_restrict'") | ||
} | ||
|
||
override fun start( | ||
ssh: SshConnection, | ||
pid: Int | ||
): RemoteMonitoringProcess { | ||
ssh.execute("./async-profiler/profiler.sh -e wall -i 9ms -b 160000000 start $pid") | ||
return ProfilerProcess(pid) | ||
} | ||
|
||
private class ProfilerProcess(private val pid: Int) : RemoteMonitoringProcess { | ||
private val flameGraphFile = "wall-clock-flamegraph.svg" | ||
|
||
override fun stop(ssh: SshConnection) { | ||
ssh.execute("./async-profiler/profiler.sh stop $pid -o svg > $flameGraphFile") | ||
} | ||
|
||
override fun getResultPath(): String { | ||
return flameGraphFile | ||
} | ||
} | ||
} | ||
@Deprecated("Use AsyncProfiler.Builder instead") | ||
class WallClockProfiler : Profiler by AsyncProfiler.Builder() | ||
.wallClockMode() | ||
.interval(Duration.ofMillis(9)) | ||
.outputFile("wall-clock-flamegraph.html") | ||
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters