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

Async profiler api upgrade #2608

Merged
merged 2 commits into from
Aug 11, 2023

Conversation

Winson-Huang
Copy link
Contributor

@Winson-Huang Winson-Huang commented Aug 10, 2023

参考 issue #2164 中的说明,首先需要升级 one.profiler。

首先分析此包本身的差异,实质性的改动有:修改了 getInstance 方法,添加了 extractEmbeddedLibgetPlatformTag 方法,其中 getPlatformTag 仅被 extractEmbeddedLib 调用,extractEmbeddedLib 仅被 getInstance 调用。

getInstance

此方法在 one.profiler 内部仅被同名无参重载方法调用。

在 ProfilerCommand 类中,此方法仅被 profilerInstance 调用(L249/271),且同名无参重载方法未被调用。

此方法内部,实际上仅改动了 libPath == null 情况的对应逻辑。L51 表示如果 jvm 进程启动时已经加载 lib,就直接返回。否则,L53~59 尝试从类路径中获取对应平台的 lib.so,复制到一个临时文件用于加载,加载后 L58 删除临时文件。如果类路径中未事先按规则准备这些 lib 文件,那么 extractEmbeddedLib 方法将返回 null,此时将与旧代码行为一致,直接从操作系统库搜索路径中查找加载 lib(若未找到则抛出错误,不会返回 profiler 实例)。总而言之,这是对已有行为的扩展而不是修改。

profilerInstance

在 ProfilerCommand.profilerInstance 方法中,在 L271 处的调用不可能传入 null 参数,因此前述改动对此无任何影响。在 L249 处的调用只有 profiler load 命令不加额外参数时才会向 getInstance 传入 null,而前述改动不会引入破坏性。

Copy code from one.profiler package of [Async Profiler project](
https://github.com/async-profiler/async-profiler/) to here, this is Java
API of Async Profiler, its version is v2.9. No need to edit contents in
this package, except package-info.java file.
@hengyunabc hengyunabc added this to the 4.0.0 milestone Aug 11, 2023
@hengyunabc hengyunabc merged commit ede9023 into alibaba:master Aug 11, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants