Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much slower does Java code with debugging info enabled run?

Tags:

java

I am wondering how much of a performance penalty there is if all the Java code I generated had debug information in it. If there is not much of a penalty then I could do things like get very useful information in production when needed without having to recompile.

like image 907
yazz.com Avatar asked Dec 28 '22 02:12

yazz.com


2 Answers

I assume that you think about line numbers and local variable names.

Both debug additions don't add extra instructions to the byte code. So the performance should be unaffected. Line numbers and variable names are just extra tables in the class files and are ignored unless you actually debug the code.


javac compiler options:

-g
    Generate all debugging information, including local variables. 
    By default, only line number and source file information is generated.

-g:none
    Do not generate any debugging information.

-g:{keyword list}
    Generate only some kinds of debugging information, specified by 
    a comma separated list of keywords. Valid keywords are:

    source
        Source file debugging information 
    lines
        Line number debugging information 
    vars
        Local variable debugging information 
like image 182
Andreas Dolk Avatar answered Mar 05 '23 19:03

Andreas Dolk


I would never debug on any production environment. If you have a problem on prod you need to try and recreate it on a dev or test environment, this is where you might debug. I guess that you've already turned all your logging up to it's highest granularity and this has failed to reveal the problem?

like image 24
Qwerky Avatar answered Mar 05 '23 17:03

Qwerky