-
Notifications
You must be signed in to change notification settings - Fork 409
[CELEBORN-1299] Introduce JVM profiling in Celeborn Worker using async-profiler #2409
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| HikariCP/4.0.3//HikariCP-4.0.3.jar | ||
| RoaringBitmap/0.9.32//RoaringBitmap-0.9.32.jar | ||
| ap-loader-all/3.0-8//ap-loader-all-3.0-8.jar | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LICENSE/NOTICE are missed |
||
| commons-cli/1.5.0//commons-cli-1.5.0.jar | ||
| commons-crypto/1.0.0//commons-crypto-1.0.0.jar | ||
| commons-io/2.13.0//commons-io-2.13.0.jar | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,9 @@ license: | | |
| | celeborn.worker.http.host | <localhost> | false | Worker's http host. | 0.4.0 | celeborn.metrics.worker.prometheus.host,celeborn.worker.metrics.prometheus.host | | ||
| | celeborn.worker.http.port | 9096 | false | Worker's http port. | 0.4.0 | celeborn.metrics.worker.prometheus.port,celeborn.worker.metrics.prometheus.port | | ||
| | celeborn.worker.internal.port | 0 | false | Internal server port on the Worker where the master nodes connect. | 0.5.0 | | | ||
| | celeborn.worker.jvmProfiler.enabled | false | false | Turn on code profiling via async_profiler in workers. | 0.5.0 | | | ||
| | celeborn.worker.jvmProfiler.localDir | . | false | Local file system path on worker where profiler output is saved. Defaults to the working directory of the worker process. | 0.5.0 | | | ||
| | celeborn.worker.jvmProfiler.options | event=wall,interval=10ms,alloc=2m,lock=10ms,chunktime=300s | false | Options to pass on to the async profiler. | 0.5.0 | | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where can I find all the option candidates and valid combinations? A detailed description or a hyperlink is required. |
||
| | celeborn.worker.jvmQuake.check.interval | 1s | false | Interval of gc behavior checking for worker jvm quake. | 0.4.0 | | | ||
| | celeborn.worker.jvmQuake.dump.enabled | true | false | Whether to heap dump for the maximum GC 'deficit' during worker jvm quake. | 0.4.0 | | | ||
| | celeborn.worker.jvmQuake.dump.path | <tmp>/jvm-quake/dump/<pid> | false | The path of heap dump for the maximum GC 'deficit' during worker jvm quake. | 0.4.0 | | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| --- | ||
| license: | | ||
| Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed with | ||
| this work for additional information regarding copyright ownership. | ||
| The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
| https://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --- | ||
|
|
||
| # JVM Profiler | ||
| Since version 0.5.0, Celeborn supports JVM sampling profiler to capture CPU and memory profiles. This article provides a detailed guide of Celeborn `Worker`'s code profiling. | ||
|
|
||
| ## Worker Code Profiling | ||
| The JVM profiler enables code profiling of workers based on the [async profiler](https://github.com/async-profiler/async-profiler/blob/v2.10/README.md), a low overhead sampling profiler. | ||
| This allows a `Worker` instance to capture CPU and memory profiles for `Worker` which is later analyzed for performance issues. | ||
| The profiler captures [Java Flight Recorder (jfr)](https://access.redhat.com/documentation/es-es/red_hat_build_of_openjdk/17/html/using_jdk_flight_recorder_with_red_hat_build_of_openjdk/openjdk-flight-recorded-overview) files for each worker that can be read by tools like Java Mission Control and Intellij etc. | ||
| The profiler writes the jfr files to the `Worker`'s working directory in the `Worker`'s local file system and the files can grow to be large, | ||
| so it is advisable that the `Worker` machines have adequate storage. | ||
|
|
||
| Code profiling is currently only supported for | ||
|
|
||
| * Linux (x64) | ||
| * Linux (arm 64) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arm64, don't split it out. |
||
| * Linux (musl, x64) | ||
| * MacOS | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "macOS" - the case is matter, let's respect the official product name https://support.apple.com/macos |
||
|
|
||
| To get maximum profiling information set the following jvm options for the `Worker` : | ||
|
|
||
| ``` | ||
| -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:+PreserveFramePointer | ||
| ``` | ||
|
|
||
| For more information on async_profiler see the [Async Profiler Manual](https://krzysztofslusarski.github.io/2022/12/12/async-manual.html). | ||
|
|
||
| To enable code profiling, enable the code profiling in the configuration. | ||
|
|
||
| ```properties | ||
| celeborn.worker.jvmProfiler.enabled true | ||
| ``` | ||
|
|
||
| For more configuration of code profiling refer to `celeborn.worker.jvmProfiler.*`. | ||
|
|
||
| ### Profiling Configuration Example | ||
| ```properties | ||
| celeborn.worker.jvmProfiler.enabled true | ||
| celeborn.worker.jvmProfiler.options event=wall,interval=10ms,alloc=2m,lock=10ms,chunktime=300s | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.celeborn.service.deploy.worker.profiler | ||
|
|
||
| import java.io.IOException | ||
|
|
||
| import one.profiler.{AsyncProfiler, AsyncProfilerLoader} | ||
|
|
||
| import org.apache.celeborn.common.CelebornConf | ||
| import org.apache.celeborn.common.internal.Logging | ||
|
|
||
| /** | ||
| * The JVM profiler provides code profiling of worker based on the the async profiler, a low overhead sampling profiler for Java. | ||
| * This allows a worker to capture CPU and memory profiles for worker which can later be analyzed for performance issues. | ||
| * The profiler captures Java Flight Recorder (jfr) files for each worker read by tools including Java Mission Control and Intellij. | ||
| * | ||
| * <p> Note: The profiler writes the jfr files to the worker's working directory in the worker's local file system and the files can grow to be large so it is advisable | ||
| * that the worker machines have adequate storage. | ||
| * | ||
| * <p>Note: code copied from Apache Spark. | ||
| * | ||
| * @param conf Celeborn configuration with jvm profiler config. | ||
| */ | ||
| class JVMProfiler(conf: CelebornConf) extends Logging { | ||
|
|
||
| private var running = false | ||
| private val enableProfiler = conf.workerJvmProfilerEnabled | ||
| private val profilerOptions = conf.workerJvmProfilerOptions | ||
| private val profilerLocalDir = conf.workerJvmProfilerLocalDir | ||
|
|
||
| private val startcmd = s"start,$profilerOptions,file=$profilerLocalDir/profile.jfr" | ||
| private val stopcmd = s"stop,$profilerOptions,file=$profilerLocalDir/profile.jfr" | ||
|
|
||
| val profiler: Option[AsyncProfiler] = { | ||
| Option( | ||
| if (enableProfiler && AsyncProfilerLoader.isSupported) AsyncProfilerLoader.load() else null) | ||
| } | ||
|
|
||
| def start(): Unit = { | ||
| if (!running) { | ||
| try { | ||
| profiler.foreach(p => { | ||
| p.execute(startcmd) | ||
| logInfo("JVM profiling started.") | ||
| running = true | ||
| }) | ||
| } catch { | ||
| case e @ (_: IllegalArgumentException | _: IllegalStateException | _: IOException) => | ||
| logError("JVM profiling aborted. Exception occurred in profiler native code: ", e) | ||
| case e: Exception => logWarning("JVM profiling aborted due to exception: ", e) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** Stops the profiling and saves output to dfs location. */ | ||
| def stop(): Unit = { | ||
| if (running) { | ||
| profiler.foreach(p => { | ||
| p.execute(stopcmd) | ||
| logInfo("JVM profiler stopped.") | ||
| running = false | ||
| }) | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible, please choose a default value independent of the working dir, the user likely uses the absolute path of the script to start the process under an arbitrary dir, which would cause indeterminate results. one solution is use
${CELEBORN_HOME}/profilingand resolve the${CELEBORN_HOME}indef workerJvmProfilerLocalDir: String