GraalVM Debugging Support module can reduce debugging performance
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
while debugging a problem I noticed a performance anomaly when I debugged NB 23 with NB 22. (JDK Corretto 22.0.2, version made no difference)
benchmark:
1. clear the test userdir (nbbuild/testuserdir/)
2. start debugging a NB module
3. create a new maven project using the dev build IDE, measure the time between pressing finish and project open
results:
```
NB run1 run2 run3
22 42s 6:33
21 46s 7:04 38s
20 1:10
19 1:05 18s
```
The first observation is that the time is vastly different between runs. But even the faster runs are surprisingly slow. This is also no recent regression since I tested even NB 19.
The second observation is that the number of JarClassLoader warnings correlated with how long it took, example warning:
```
WARNING [org.netbeans.JarClassLoader]: Opening /home/mbien/NetBeansProjects/netbeans/nbbuild/netbeans/ide/modules/ext/truffle-api-24.0.0.jar took 651 ms
```
(there can be a lot of repeating warnings)
async profiler flamegraph showed that a most of the time is spent in `org.graalvm.polyglot.*` codepaths.
[truffle_debug.html.zip](https://github.com/user-attachments/files/16576462/truffle_debug.html.zip)
[GraalEnginesProvider#enumarateLanguages](https://github.com/apache/netbeans/blob/f6e767325d4c98363794065ba60e559424ae1c2a/ide/libs.graalsdk/src/org/netbeans/libs/graalsdk/impl/GraalEnginesProvider.java#L149) specifically.
to verify this I uninstalled `GraalVM Debugging Support` and tested again:
```
NB run1 run2
22 2s 3s
```
(don't uninstall the module in your "production" IDE)
Debugging did still work.
This is going to need some more investigations.
Contributor guide
Research direction
Start with ide/libs.graalsdk/src/org/netbeans/libs/graalsdk/impl/GraalEnginesProvider.java, especially GraalEnginesProvider#enumarateLanguages, then reproduce the benchmark after clearing nbbuild/testuserdir/. Compare startup with GraalVM Debugging Support enabled and uninstalled, using the async-profiler flamegraph and JarClassLoader warnings. Done means the performance cause is identified and a change can be verified without breaking debugging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100