kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
173 stars 57 forks source link

Implement / activate perdormance profiling menu for Gradle projects #394

Open gavenkoa opened 6 years ago

gavenkoa commented 6 years ago

It seems that plugin doesn't have support for application profiling.

Menu items for setting profiling breakpoints and launching profiles are disabled...

kelemen commented 6 years ago

The problem is that NB needs the pid of the started java process but I can't get the pid from the Gradle task. So, as is now, you need to start the process and then attach to it.

gavenkoa commented 6 years ago

Actually I haven't thought about attaching to process, managed by Gradle.

I think about launching "main" method with provided by Gradle classpath. That way it is possible to reuse profiler startup logic from Maven implementation...

There is option for attaching to running process and https://visualvm.github.io/startupprofiler.html for profiling startup.

I adore profiling breakpoints so only selected part of application will be profiled in automated / reproducible way. But menu item for placing breakpoints is disabled (that is "Insert profiling point")

kelemen commented 6 years ago

Though currently, practically every action is associated with a Gradle command, so it would be a little inconsistent (i.e., starting the process via the profiler would ignore whatever was configured for the run task). Also, this is a bigger change since currently there is nothing in the code to support manually forking a new JVM and track that process.

tcfurrer commented 6 years ago

Has anyone already requested a Gradle enhancement to provide the java process ID?

Also... this seems overlapping with the previous issue: https://github.com/kelemen/netbeans-gradle-project/issues/106

kelemen commented 6 years ago

I don't know of such a request. It is a deeper issue than just getting the process ID for two reasons:

  1. The execute method of Gradle tasks block and so you can't simply just get the PID after starting.
  2. As far as I know there is no generic mechanism for the build to call back to the IDE (or whatever using the Tooling API). There are some special cases (like testing), so I'm guessing it wouldn't be impossible for Gradle.