AdoptOpenJDK / jitwatch

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.
Other
3.04k stars 435 forks source link

how to set config for openjdk built by source files #354

Closed liusy58 closed 2 years ago

liusy58 commented 2 years ago

hi, I build the OpenJDK17 source file and I want to use JITWatch, but I can not set config correctly, any help?

liusy58 commented 2 years ago

Screenshot from 2021-11-12 11-21-08

the error message is below:

11:10:50.887 [JavaFX Application Thread] WARN  o.a.j.c.CompilationUtil - No Task found in Compilation 11
Exception in thread "Thread-11" java.util.EmptyStackException
        at java.base/java.util.Stack.peek(Stack.java:101)
        at java.base/java.util.Stack.pop(Stack.java:83)
        at org.adoptopenjdk.jitwatch.core.TagProcessor.handleTag(TagProcessor.java:140)
        at org.adoptopenjdk.jitwatch.core.TagProcessor.processLine(TagProcessor.java:57)
        at org.adoptopenjdk.jitwatch.parser.hotspot.HotSpotLogParser.parseLogCompilationLines(HotSpotLogParser.java:148)
        at org.adoptopenjdk.jitwatch.parser.hotspot.HotSpotLogParser.parseLogFile(HotSpotLogParser.java:130)
        at org.adoptopenjdk.jitwatch.parser.AbstractLogParser.processLogFile(AbstractLogParser.java:366)
        at org.adoptopenjdk.jitwatch.parser.ILogParser.processLogFile(ILogParser.java:23)
        at org.adoptopenjdk.jitwatch.ui.main.JITWatchUI$1.run(JITWatchUI.java:246)
        at java.base/java.lang.Thread.run(Thread.java:831)
Exception in thread "Thread-12" java.util.EmptyStackException
        at java.base/java.util.Stack.peek(Stack.java:101)
        at java.base/java.util.Stack.pop(Stack.java:83)
        at org.adoptopenjdk.jitwatch.core.TagProcessor.handleTag(TagProcessor.java:140)
        at org.adoptopenjdk.jitwatch.core.TagProcessor.processLine(TagProcessor.java:57)
        at org.adoptopenjdk.jitwatch.parser.hotspot.HotSpotLogParser.parseLogCompilationLines(HotSpotLogParser.java:148)
        at org.adoptopenjdk.jitwatch.parser.hotspot.HotSpotLogParser.parseLogFile(HotSpotLogParser.java:130)
        at org.adoptopenjdk.jitwatch.parser.AbstractLogParser.processLogFile(AbstractLogParser.java:366)
        at org.adoptopenjdk.jitwatch.parser.ILogParser.processLogFile(ILogParser.java:23)
        at org.adoptopenjdk.jitwatch.ui.main.JITWatchUI$1.run(JITWatchUI.java:246)
        at java.base/java.lang.Thread.run(Thread.java:831)
chriswhocodes commented 2 years ago

Hi, please can you share the source/class file and the command line options used to run it?

Thanks,

Chris

liusy58 commented 2 years ago

Hi, Chris, sorry for my late reply. My command-line option is java -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:-TieredCompilation -XX:+PrintAssembly -XX:-UseCompressedOops sumBenchmark.java

The source file is

import java.io.IOException;

import java.nio.file.*;
public class sumBenchmark {
    public int count(int n) {
        int res = 0;
        for(int i=1;i<=n;++i){
            if(i%2 == 1){
                res  += i;
            }else{
                res -= i;
            }
        }
        return res;
    }
    public static void main(String[] args) {
        int res =0;
        sumBenchmark summer = new sumBenchmark();

        for(int i=1;i<=10000;++i){
            res += summer.count(i);
        }
        System.out.println(res);
    }
}
chriswhocodes commented 2 years ago

TriView-snapshot-2021 11 13 13 14 30 Hi, OpenJDK17 (Temurin) seems to work for me. Are you running your code in the JITWatch "Sandbox" or analysing a LogCompilation file your output from an execution outside JITWatch?

If the latter then please can you paste your logcompilation file please?

Also, is the problem repeatable? Sometimes with short programs the JVM exits before completely writing the logcompilation file so you don't get a usable log file.

Cheers,

Chris

liusy58 commented 2 years ago

Yeah, the latter one, this problem is repeatable. I think I do not correctly understand the JITWatch Configuration, I'll try running my code in the JITWatch "Sandbox". So could you please tell see your settings about source locations and class locations?

Thank you, Chris.

chriswhocodes commented 2 years ago

Hi, with the sandbox it automatically finds your source and class locations. Manual configuration is only needed for external log files :)

liusy58 commented 2 years ago

Okay, I'll try later. Thank you for your patience. By the way, are you familiar with JVM execution engine about JIT? I mean the logic about C1 compiler and C2 compiler, especially the code emit phase, the optimization technology is not what I care, I only care about the phase from lir to native code. The source code really puzzles me, any help?

chriswhocodes commented 2 years ago

I know a little but the hotspot-compiler-dev mailing list is the best place to ask about compiler internals :)

liusy58 commented 2 years ago

Okay, thank you a lot!!! Have a nice day!!!!

liusy58 commented 2 years ago

Hi, Chris, sorry to disturb you again, I sent emails to hotspot-compiler-dev mailing list, but no response. Any help?

chriswhocodes commented 2 years ago

Hi, I'm closing all the issues except for the ones I'm actively working on.