FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support async profiler feature by zhengziyi0117 · Pull Request #720 · apache/skywalking-java · GitHub

Support async profiler feature - #720

Merged
wu-sheng merged 32 commits into
apache:mainfrom
zhengziyi0117:async-profiler
Oct 30, 2024
Merged

Support async profiler feature#720
wu-sheng merged 32 commits into
apache:mainfrom
zhengziyi0117:async-profiler

Conversation

Copy link
Copy Markdown
Contributor

Integrate async profiler performance analysis function in Java

  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
  • Update the CHANGES log.

lujiajing1126 added the enhancement New feature or request label Oct 25, 2024

Copy link
Copy Markdown
Contributor

Pls fix CI

lujiajing1126 added this to the 9.4.0 milestone Oct 25, 2024
zhengziyi0117 and others added 7 commits October 25, 2024 15:12
…/apm/agent/core/conf/Config.java

Co-authored-by: Jiajing LU <lujiajing1126@gmail.com>
…/apm/agent/core/conf/Config.java

Co-authored-by: Jiajing LU <lujiajing1126@gmail.com>
…/apm/agent/core/conf/Config.java

Co-authored-by: Jiajing LU <lujiajing1126@gmail.com>
…/apm/agent/core/conf/Config.java

Co-authored-by: Jiajing LU <lujiajing1126@gmail.com>
lujiajing1126 self-requested a review October 28, 2024 02:12
* Wait briefly to see if the server can receive the jfr. If the server cannot receive it, onError will be triggered.
* Then we wait for a while (waiting for the server to send onError) and then decide whether to send the jfr file.
*/
Thread.sleep(500);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@wu-sheng In the current design, the Java Agent has to wait after the first request in order to determine whether the OAP accepts the following data transfer. This is a kind of negotiation.

WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If you need to wait for the server, you should change AsyncProfilerTask service to dual streaming, and the response needs to be a kind of ack

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

500ms can't guarantee anything AFAIK.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If you need to wait for the server, you should change AsyncProfilerTask service to dual streaming, and the response needs to be a kind of ack

Sure. Let's use dual streaming @zhengziyi0117

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note, in this case, Command should not be the response anymore.

*/
Thread.sleep(500);

// Is it possible to upload jfr?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What does this comment mean?

Comment thread pom.xml Outdated
Comment on lines +217 to +221
<dependency>
<groupId>tools.profiler</groupId>
<artifactId>async-profiler</artifactId>
<version>${async-profiler.version}</version>
</dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please move this the last one rather than the first.

Comment thread pom.xml Outdated

<!-- core lib dependency -->
<bytebuddy.version>1.14.9</bytebuddy.version>
<async-profiler.version>3.0</async-profiler.version>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please move this the last one rather than the first.

lujiajing1126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM if all the current comments are resolved


@Override
public void shutdown() throws Throwable {
scheduledFuture.cancel(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

you have to check NULL!

Comment on lines +67 to +69
Commands commands = asyncProfilerTaskBlockingStub.withDeadlineAfter(GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS)
.getAsyncProfilerTaskCommands(query);
ServiceManager.INSTANCE.findService(CommandService.class).receiveCommand(commands);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You should check service not implemented error of gRPC, you could try that by connecting v < 10.1 OAP.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Once it is not implemented, the agent should shutdown this part automatically.

Comment thread apm-sniffer/config/agent.config Outdated
profile.dump_max_stack_depth=${SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH:500}
# Snapshot transport to backend buffer size
profile.snapshot_transport_buffer_size=${SW_AGENT_PROFILE_SNAPSHOT_TRANSPORT_BUFFER_SIZE:4500}
# If true, Async Profiler will be enabled when user creates a new async profiler task, Otherwise it is disabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This comment is not accurate. You hard coded this value as true, so, the default value is TRUE, not disabled. Please update your default value in the codes.

@DefaultImplementor
public class AsyncProfilerDataSender implements BootService, GRPCChannelListener {
private static final ILog LOGGER = LogManager.getLogger(ProfileSnapshotSender.class);
private static final int DATA_CHUNK_SIZE = 1024 * 1024;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This should move into config. Don't have to expose through agent.config, but we don't need to hard code this.

Comment on lines +170 to +171
status.finished();
ServiceManager.INSTANCE.findService(GRPCChannelManager.class).reportError(t);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

When onError, we should output logs.


private static final ILog LOGGER = LogManager.getLogger(AsyncProfilerTaskChannelService.class);

private static final AsyncProfiler ASYNC_PROFILER = AsyncProfiler.getInstance();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please use lazy initialization as much as possible. I am not sure how much effects would this getInstance takes, but as service list is loaded before agent instrumentation, we should load as less code as possible. Otherwise, the instrumentation could fail due to classes have been loaded.

private static final String SUCCESS_RESULT = "Profiling started\n";

// profile executor thread pool, only running one thread
private static final ScheduledExecutorService ASYNC_PROFILER_EXECUTOR = Executors.newSingleThreadScheduledExecutor(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same here, please initialize later in the process.

zhengziyi and others added 2 commits October 30, 2024 15:06
…/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java

Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
zhengziyi and others added 6 commits October 30, 2024 15:13
…/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java

Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
…/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java

Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
lujiajing1126 previously approved these changes Oct 30, 2024

lujiajing1126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

return;
}
final StatusRuntimeException statusRuntimeException = (StatusRuntimeException) t;
if (statusRuntimeException.getStatus().getCode() == Status.Code.UNIMPLEMENTED) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please use Status.Code.UNIMPLEMENTED.equals. It is safer.

wu-sheng merged commit 2027a98 into apache:main Oct 30, 2024
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL