You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "jtulach (via GitHub)" <gi...@apache.org> on 2026/01/14 18:33:53 UTC

[PR] Speeding up Truffle debugging [netbeans]

jtulach opened a new pull request, #9142:
URL: https://github.com/apache/netbeans/pull/9142

   - while working on https://github.com/enso-org/enso/pull/14632 I had to debug a lot
   - it takes 40s to reach breakpoint
   - Commenting out this line speeds Truffle debugger 10 times: 9e24c441f2902188bebdf83897dd1188472485dc
   
   <img width="1201" height="799" alt="image" src="https://github.com/user-attachments/assets/9d8000b3-5d48-45f8-8949-14c7d05ec7c3" />
   
   - of course, commenting out this line is not an option
   - my goal in this PR is to speed the initialization while making the rest of the Truffle debugging functional


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#discussion_r2772203723


##########
java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/TruffleDebugManager.java:
##########
@@ -59,43 +59,50 @@
  */
 @DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
 public class TruffleDebugManager extends DebuggerManagerAdapter {
-    
+
     private static final Logger LOG = Logger.getLogger(TruffleDebugManager.class.getName());
-    
+
     private static final String ENGINE_CLASS = "org.graalvm.polyglot.Engine";   // NOI18N
     private static final String ENGINE_BUILDER_CLASS = "org.graalvm.polyglot.Engine$Builder";   // NOI18N
+    private static final String POLY_IMPL_CLASS = "com.oracle.truffle.polyglot.PolyglotImpl";   // NOI18N
+    private static final String POLY_IMPL_BUILD_METHOD = "buildEngine";   // NOI18N

Review Comment:
   > test if `PolyglotImpl.buildEngine()` is there and if yes then use it, if not then fall back to the public method.
   
   That's would be optimal and robust! Now I just need to find out how to test for existence of a method in the debuggee?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#issuecomment-3779974605

   > would be also curious to find out why the debugger has to call into polyglot/GraalEngine code when the maven new-project wizard runs
   
   It's not specific to Maven.  Same happens with other project types (eg. Ant and PHP).  I'd initially thought something was triggered during cluster activation, but it's later during the new project creation.  Seems to happen on first use of new project on subsequent runs too?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#issuecomment-3779688361

   > > wondering if there is a relation to #7663
   > 
   >    * probably yes.
   > 
   >    * If applying [9e24c44](https://github.com/apache/netbeans/commit/9e24c441f2902188bebdf83897dd1188472485dc) speeds your case up, then yes,
   > 
   >    * it is probably the _exit method breakpoint_ cause
   
   commenting the `addBreakpoint()` call out appears to resolve the performance problem. But please note that the current version of this PR has it commented in and the problem does occur. (I didn't test anything else, e.g if the breakpoints still work)
   
   also please note that none of the debugger tests ran so far, i added the labels which will enable them on next sync.
   
   would be also curious to find out why the debugger has to call into polyglot/GraalEngine code when the maven new-project wizard runs


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#issuecomment-3780113646

   >  Same happens with other project types (eg. Ant and PHP).
   
   interesting, didn't know that. I thought i tested the ant wizard as baseline and it worked fine, but it was a while ago by now.
   
   > I'd initially thought something was triggered during cluster activation, but it's later during the new project creation. Seems to happen on first use of new project on subsequent runs too?
   
   at least in case of maven, second run within the same session is faster since there is quite some maven initialization going on during first run. https://github.com/apache/netbeans/pull/7590, however usually this is <2s and it happens before you can click next. First run performance while debugging is completely upredictable, the slowest run was 7mins, some were 40s. The issue has more info, bencharmks and flame graphs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on code in PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#discussion_r2752886583


##########
java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/TruffleDebugManager.java:
##########
@@ -59,43 +59,50 @@
  */
 @DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
 public class TruffleDebugManager extends DebuggerManagerAdapter {
-    
+
     private static final Logger LOG = Logger.getLogger(TruffleDebugManager.class.getName());
-    
+
     private static final String ENGINE_CLASS = "org.graalvm.polyglot.Engine";   // NOI18N
     private static final String ENGINE_BUILDER_CLASS = "org.graalvm.polyglot.Engine$Builder";   // NOI18N
+    private static final String POLY_IMPL_CLASS = "com.oracle.truffle.polyglot.PolyglotImpl";   // NOI18N
+    private static final String POLY_IMPL_BUILD_METHOD = "buildEngine";   // NOI18N

Review Comment:
   - the big question to ask:
   - _can we rely on `com.oracle.truffle.polyglot.PolyglotImpl.buildEngine` being there_  in subsequent releases of Truffle API?
   - `Engine.Builder.build()` was an official API - it is not going to go away
   - `PolyglotImpl.buildEngine(...)` is just an implementation
   - but the speedup improvement is tempting



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "entlicher (via GitHub)" <gi...@apache.org>.
entlicher commented on code in PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#discussion_r2756338301


##########
java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/TruffleDebugManager.java:
##########
@@ -59,43 +59,50 @@
  */
 @DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
 public class TruffleDebugManager extends DebuggerManagerAdapter {
-    
+
     private static final Logger LOG = Logger.getLogger(TruffleDebugManager.class.getName());
-    
+
     private static final String ENGINE_CLASS = "org.graalvm.polyglot.Engine";   // NOI18N
     private static final String ENGINE_BUILDER_CLASS = "org.graalvm.polyglot.Engine$Builder";   // NOI18N
+    private static final String POLY_IMPL_CLASS = "com.oracle.truffle.polyglot.PolyglotImpl";   // NOI18N
+    private static final String POLY_IMPL_BUILD_METHOD = "buildEngine";   // NOI18N

Review Comment:
   This might be an option, even though it's prone to break when the impl changes. I don't expect Truffle to change much these days, it's much more mature than it was during the engines and instrumentation development, which broke our Truffle debugger in the past. Even though we never know what happens to the private stuff.
   
   I'll test the class loading order - maybe we could test if PolyglotImpl.buildEngine() is there and if yes then use it, if not then fall back to the public method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#issuecomment-3751070169

   wondering if there is a relation to https://github.com/apache/netbeans/issues/7663


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Speeding up Truffle debugging [netbeans]

Posted by "jtulach (via GitHub)" <gi...@apache.org>.
jtulach commented on PR #9142:
URL: https://github.com/apache/netbeans/pull/9142#issuecomment-3760598688

   - it seems that the _exit method breakpoints_ prevent OpenJDK from optimizing properly
   - maybe installing such a breakpoint forces running in interpreter mode?
   - avoiding the _exit method breakpoint_ or installing it for _as little as possible_ shall improve the poor 40s delay
   
   > * of course, commenting out this line is not an option
   > * my goal in this PR is to speed the initialization while making the rest of the Truffle debugging functional
   
   - with 6268481 I managed to get the time down to 10s
   - that is still more than 4s without installing the _exit method breakpoint_ on `Engine.build()` 
   - but it is better than previous 40s
   
   > wondering if there is a relation to #7663
   
   - probably yes. 
   - If applying 9e24c441f2902188bebdf83897dd1188472485dc speeds your case up, then yes, 
   - it is probably the _exit method breakpoint_ cause


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists