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

Exclude virtual threads from inferred spans feature #3244

Merged
merged 14 commits into from
Aug 10, 2023

Conversation

JonasKunz
Copy link
Contributor

@JonasKunz JonasKunz commented Jul 18, 2023

What does this PR do?

Excludes virtual threads from the inferred spans feature. Before doing this I did a short test, showing that our async-profiler version can't deal with virtual threads switching their carrier thread.

Checklist

@JonasKunz JonasKunz added the ci:jdk-compatibility Enables JDK compatibility tests in build pipeline label Jul 18, 2023
@JonasKunz JonasKunz marked this pull request as ready for review August 9, 2023 10:10
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

/test

Comment on lines +42 to +54
/**
* Generates a VirtualChecker based on the current JVM.
* If the JVM does not support virtual threads, a VirtualChecker which always returns false is returned.
* <p>
* Otherwise we runtime generate an implementation which invokes Thread.isVirtual().
* We use runtime proxy generation because Thread.isVirtual() has been added in Java 19 as preview and Java 21 as non preview.
* Therefore we would require a compilation with Java 19 (non-LTS), because Java 20+ does not allow targeting Java 7.
* <p>
* Alternatively we could simply invoke Thread.isVirtual via reflection.
* However, because this check can be used very frequently we want to avoid the penalty / missing inline capability of reflection.
*
* @return the implementation for {@link VirtualChecker}.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Nice ! I think that's definitely a good approach we could use for other deprecated or soon-to-be-removed APIs like the security manager.

@JonasKunz JonasKunz merged commit 796c694 into elastic:main Aug 10, 2023
14 checks passed
@JonasKunz JonasKunz deleted the loom-async-profiler branch August 10, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-java ci:jdk-compatibility Enables JDK compatibility tests in build pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants