KEMBAR78
Make comp-task matching more generic by Baraa-Hasheesh · Pull Request #1474 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

@Baraa-Hasheesh
Copy link
Contributor

Description

testCompTask checks that the compfeature is working, by checking for the synthetic frames async-profiler adds
These synthetic frames can be for classes outside of the java/lang package

For example

;C2Compiler::compile_method;sun/util/locale/LocaleUtils.caseIgnoreMatch
;C2Compiler::compile_method;jdk/internal/loader/URLClassPath.getLoader
;Compiler::compile_method;sun/net/www/protocol/jar/Handler.parseContextSpec
;Compiler::compile_method;jdk/internal/loader/URLClassPath$JarLoader$1.run

This change allows for a more generic matching reducing the possibility of failures

Related issues

N/A

Motivation and context

Reduce possibility for test failure

How has this been tested?

manual testing


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

assert p.exitCode() == 0;
assert out.contains(";Compiler::compile_method;java/lang/\\w+\\.");
assert out.contains(";C2Compiler::compile_method;java/lang/\\w+\\.");
assert out.contains(";Compiler::compile_method;(java|sun|jdk)/.*");
Copy link
Contributor

@fandreuz fandreuz Sep 11, 2025

Choose a reason for hiding this comment

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

I wonder if we really need to be explicit here. Do we really care what package the compiled method is coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

are you suggesting checking against \\w+/.*to match any packages that might be external?

In this case I don't really see the need as the test is plain JDK test which should always start from the above packages (sun,java,jdk)

Copy link
Contributor

@fandreuz fandreuz Sep 11, 2025

Choose a reason for hiding this comment

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

are you suggesting checking against \w+/.*to match any packages that might be external?

Yes. But I'm not saying we should target external packages, just that perhaps we don't care about the package we catch here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should care about the base package name as that acts as a simple sanity test that async-profiler is adding logical frames to the generated stacks

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough

Copy link
Member

@apangin apangin Sep 11, 2025

Choose a reason for hiding this comment

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

Thanks, but my question is different. How come that none of basic java/lang classes (String, Thread, Class, etc.) were seen in the compilation profile? Weren't these methods compiled, or they were but async-profiler did not catch any? How can I reproduce the issue? (Haven't seen it so far)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm attaching some flame graphs, when checked both show that both C1 & C2 compiler are working fine & are being sampled as we expect them to,

image

It's just that C1 compiler is simply fast & sometimes is not sampled for the classes/methods directly under java/lang package
=> Reducing the sampling interval increases the stability of the test.

If we check the available samples for C1 we can see the synthetic frames & we can see that each method was sampled only once which is what we expect to see

Due to the high performance of C1 it was possible for certain runs to not capture samples for the methods we currently expect, as such changing the pattern was needed,

I didn't see a value in picking one package over another as we may fall into the same issue in the future, so I opted for a pattern that should match any java synthetic frame

image

The java/lang can be still be seen on C2 compiler, and each method is only sampled once which is what we expect to see.
However to keep the check uniform, I opted to change the pattern for C2 as well.

flamegraph.html
flamegraph2.html

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, that makes sense.
The pattern, however, does not make difference between a class name and a method name. I'd like the test verify that it's a Java method that is inserted as a synthetic frame, i.e. frame name contains one dot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that make sense, I will update the pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pattern update to better match java methods

New pattern (java|sun|jdk)/[^;]+[^;/]\.[^;/]+

  • (java|sun|jdk) => top package sanity check
  • /[^;]+ => checks for nested packages
  • [^;/].[^;/]+ => checks a method name that shouldn't contain "/;" characters & should have a "." in it

@apangin apangin merged commit 6fc51db into async-profiler:master Sep 11, 2025
20 checks passed
krk pushed a commit to krk/async-profiler that referenced this pull request Sep 22, 2025
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.

3 participants