Skip to content

Add support for profiling Gradle tasks#1639

Merged
jdneo merged 3 commits intomicrosoft:developfrom
ingokegel:addtional_tool_options
Apr 2, 2025
Merged

Add support for profiling Gradle tasks#1639
jdneo merged 3 commits intomicrosoft:developfrom
ingokegel:addtional_tool_options

Conversation

@ingokegel
Copy link
Contributor

JProfiler 15 will add VS Code integration and as part of that effort we would like to support profiling Gradle tasks as well. To accomplish that, we need to add an -agentpath VM parameter to a Java invocation that is launcher from the Gradle build.

To allow profilers to add their VM parameters, a registerToolOptionsProvider function was added to the API. When a build is run, the VM parameters are queried from all registered tool option providers, concatenated and sent to the Gradle server where they are added to the JAVA_TOOL_OPTIONS along with the debugger VM parameter.

@ingokegel
Copy link
Contributor Author

ingokegel commented Jan 2, 2025 via email

@jdneo
Copy link
Member

jdneo commented Jan 6, 2025

Hi @ingokegel,

Thank you for your contribution.

The PR looks good to me.

May I ask if there is any bit I can use to test the integration?

@ingokegel
Copy link
Contributor Author

@jdneo I've added a commit with a test extension that sets a system property via the new mechanism. Is that what you were looking for?

@jdneo
Copy link
Member

jdneo commented Jan 7, 2025

Thank you @ingokegel.

Sorry I did not say it clearly. (It's good to have it for testing though!) I would like to know from customer perspective, how they can use this new feature? Is that a JProfiler vscode extension using this new API? How is the E2E experience looks like?

From our side, these can be some useful materials that we can mention and tell our customers in our feature update blog for VS Code Java.

// fyi @nickzhums

@ingokegel
Copy link
Contributor Author

Is that a JProfiler vscode extension using this new API?

Yes, exactly. The JProfiler VS Code extension has a toggle action for profiling. If enabled, launch configurations are profiled and the JProfiler UI is opened when a launch configuration is started. Benefits of such an IDE integration include:

  • You can profile existing launch configurations without any additional setup in JProfiler
  • Source navigation from JProfiler will be performed in the IDE.
  • JProfiler is informed about the packages in the source roots and that information is used to set filters for method call recording

For the VS Code Gradle extension, we need this new functionality so that JProfiler can insert an additional VM parameter that loads the profiling agent when a Gradle task is executed.

How is the E2E experience looks like?

The user will not be dealing with the API, it is just used by the JProfiler VS Code extension. Other profilers can also use this API, there is nothing specific regarding JProfiler about it.

@jdneo
Copy link
Member

jdneo commented Jan 8, 2025

May I ask is the JProfiler VS Code extension available now? I tried to find it in the marketplace but did not find it.

@ingokegel
Copy link
Contributor Author

No, it is not published yet because it requires JProfiler 15 which has not yet been released.

@jdneo
Copy link
Member

jdneo commented Jan 8, 2025

I see.

Would you mind me holding this PR until the JProfile extension is about to be released?

If you need a vsix with this change, I can build one for you.

@ingokegel
Copy link
Contributor Author

No problem, I will let you know once we have an RC.

If you need a vsix with this change, I can build one for you.

Thanks, but I did manage to build the vsix for testing the JProfiler VS Code extension.

@jdneo
Copy link
Member

jdneo commented Jan 9, 2025

OK, cool!

@ingokegel ingokegel force-pushed the addtional_tool_options branch from e5af64a to b9e819d Compare March 12, 2025 16:03
@ingokegel ingokegel force-pushed the addtional_tool_options branch from b9e819d to 66711c5 Compare April 1, 2025 07:37
@ingokegel
Copy link
Contributor Author

@jdneo JProfiler 15 has been released! The VS Code integration can be found at

https://marketplace.visualstudio.com/items?itemName=ejtech.jprofiler

It already contains support for profiling Gradle tasks if this pull request is merged.

@jdneo jdneo merged commit 07b8ecf into microsoft:develop Apr 2, 2025
5 checks passed
@jdneo
Copy link
Member

jdneo commented Apr 2, 2025

Thank you @ingokegel

@jdneo
Copy link
Member

jdneo commented Apr 2, 2025

A pre-release 3.17.2025040205 is published

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