Solved

the java native mode

Posted on 2014-03-07
19
374 Views
Last Modified: 2014-03-16
Dear all,

From time to time , we can see that the java mode we are using is x64 mixed mode and what is the benefit of changing from mixed mode to native mode?


 how to change it please ?
0
Comment
Question by:marrowyung
  • 9
  • 9
19 Comments
 
LVL 1

Author Comment

by:marrowyung
ID: 39914253
on this sense, the application already running the java run time, like javaw.exe should be able to take advantage on it.

Any parameter for javaw.exe to change to take advantage on the native mode?

e.g.:

"D:\Program Files\Java\jre7\bin\javaw.exe" -cp jts.jar;total.2012.jar -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true -Xmx768M -XX:MaxPermSize=128M jclient/LoginFrame 

Open in new window


?
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39915122
You can force the JVM into native mode with the -Xcomp flag, but performance will frequently suffer.  

-Xcomp revents ANY code from running interpreted - even if it only runs once and running interpreted would be faster than compiling it.  Still, there are cases where a particular application may benefit from -Xcomp.  

No harm in testing it.

Just be aware that if the runtime characteristics of your application change, the JVM won't be able to adapt and make an intelligent decision if you are not running in mixed mode.  

https://blog.codecentric.de/en/2012/07/useful-jvm-flags-part-1-jvm-types-and-compiler-modes/
0
 
LVL 20

Expert Comment

by:Amitkumar Panchal
ID: 39915224
Agree with Gary. For more information refer the link provided by him.
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39916610
"You can force the JVM into native mode with the -Xcomp flag, but performance will frequently suffer.  "

you mean thing in my command need to remove  and add this one ?

so the final verions is:

"D:\Program Files\Java\jre7\bin\javaw.exe" -cp jts.jar;total.2012.jar -Xcomp -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true -Xmx768M -XX:MaxPermSize=128M jclient/LoginFrame

?

I will run mulit threading java financial application, what will be the benefit of using Native mode ?
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39916688
What is the mixed mode, compiled mode and interpreted mode ?
0
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 39917454
so the final verions is:

"D:\Program Files\Java\jre7\bin\javaw.exe" -cp jts.jar;total.2012.jar -Xcomp -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true -Xmx768M -XX:MaxPermSize=128M jclient/LoginFrame

yes

I will run mulit threading java financial application, what will be the benefit of using Native mode

Performance will probably be worse in this kind of application in native mode.  You should run in mixed mode.  That is why mixed mode is the default - it provides the best performance for most applications.

What is the mixed mode, compiled mode and interpreted mode ?


Read the article I posted the link to.  I think it answers all these questions pretty clearly.
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39919476
That option will only slow down that appliation after test on 2 x PC I have, one icore 7 3rd edition and one Xeon E-xxxx.

Both slower than mixed mode,

"Performance will probably be worse in this kind of application in native mode. "

why is it ?
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39919477
"Read the article I posted the link to.  I think it answers all these questions pretty clearly. "

I don't think that article tells clearly, sorry about that.
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39920629
OK, let's take this one bit at a time.  There are three modes:

1) Interpreted mode:  All bytecode is interpreted.

2) Native mode: All bytecode is compiled before it is executed.

3) Mixed mode:  JIT compiler can elect to interpret some code, and compile some code.  It takes time to compile code, so if a chunk of code is only used once, it may be faster to just interpret it.

Do you have any questions about that part?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39920648
That option will only slow down that appliation after test on 2 x PC I have, one icore 7 3rd edition and one Xeon E-xxxx.


I don't understand what you mean.

Both slower than mixed mode,

Yes, I would expect both interpreted and native mode to be slower than mixed mode for most applications.  Is that what happened when you tested?

Do you have a question?
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39920653
"Performance will probably be worse in this kind of application in native mode. "

why is it ?


Because mixed mode lets the JIT compiler optimize runtime by deciding to interpret or compile on a case-by-case basis, depending on what it determines may be faster.

It takes time to compile, so for code that doesn't get executed frequently, it can be faster to just interpret it than to compile and then execute the compiled code.
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39920713
I don't think that article tells clearly, sorry about that.

OK, so now that you've read the article, do you have any specific questions about it that I can help you understand?  I don't know what your background is.  I don't know if you know what "interpreted" vs "compiled" means.  I don't know if you understand JIT compilation - unless you ask more specific questions.  

Just saying "I don't understand" makes it hard to figure out what needs to be explained.

This isn't a very complicated topic - there are only three options:  

1) For code that gets executed repeatedly in a loop, compiling the code once and then executing the compiled code repeatedly is generally faster than interpreting it.

2) For code that is not executed repeatedly in a loop, interpreted mode is generally faster than compiling and then executing.

3) But since most applications have both kids of code - mixed-mode usually performs the best, and that is why it is the default.

Here is a good basic description of mixed-mode from Sun:

http://docs.oracle.com/cd/E19455-01/806-1367/ch2features-23/index.html
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39922532
"That option will only slow down that appliation after test on 2 x PC I have, one icore 7 3rd edition and one Xeon E-xxxx."

I mean it is not hardware performance problem.

"Yes, I would expect both interpreted and native mode to be slower than mixed mode for most applications.  Is that what happened when you tested?"

I only text mixed mode and native mode.

"
It takes time to compile, so for code that doesn't get executed frequently, it can be faster to just interpret it than to compile and then execute the compiled code. "

right now here, interpret means it still not complied it but why interpret ? it has to complite before it use, right?

"OK, so now that you've read the article, do you have any specific questions about it that I can help you understand?  I don't know what your background is.  I don't know if you know what "interpreted" vs "compiled" means. "

exactly ! I don't know, I am not a developer ! thanks for coaching me a lot !

"2) For code that is not executed repeatedly in a loop, interpreted mode is generally faster than compiling and then executing.

you are developer !?

"3) But since most applications have both kids of code - mixed-mode usually performs the best, and that is why it is the default."

get it !! I think and believe.
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39922690
right now here, interpret means it still not complied it but why interpret ? it has to complile before it use, right?

No.  Java is an interpreted language.  Sometimes we use the term "compile" when we use javac - but that's really just conversion from human-readable Java to more compact Java bytecode.

Compiled languages have to be compiled separately for each hardware platform and OS that they run on.  Interpreted languages are executed dynamically in a special runtime environment (JRE for Java, php for php) that understands how to execute each line of code as it is encountered at runtime.

Compiled languages tend to be fast, but less portable.

Interpreted languages tend to run slower, but are more portable.

To speed Java up, a feature called "just-in-time compilation" was created (JIT) which helps speed Java up by compiling certain methods to native machine language at runtime.  This speeds up execution of methods that are executed many times.  But this compilation process happens every time a program is run., unlike true compiled languages.

you are developer !?

Yes.  I've been a professional programmer since 1988.
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39922839
"To speed Java up, a feature called "just-in-time compilation" was created (JIT) which helps speed Java up by compiling certain methods to native machine language at runtime.  This speeds up execution of methods that are executed many times.  But this compilation process happens every time a program is run., unlike true compiled languages."

ok, mixed mode is the fastest anyway !!

you know oracle ? you know Oracle procedure, package and function programming ?
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39923648
My primary database platform is DB2 on IBM i, but I am also familiar with Oracle.
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39925476
good! DB2 is good ?

right now we have a project to migrate DB2 V8.1 to MS SQL, our DB2 8.1 is very bad that the memory configuration has to be tune manually.

Recently that I think there are some kind of hardwre failure as ONLY some times that the application keep prompting errors and later on we reboot it, it is ok ! the error is heap memory problem !

Then we found that we have no choice to recalculate the memory usage ourselves, what ? the DB is not going to handle it automatically !!

but I heard that since DB V9, it will be much better !

Now I have the task of Oracle data auditing that need to build trigger as we need data level trigger instead of action level.

I have done the MySQL one and I am happy with this, this involve a lot of dynamically, package, function programming, hope you keep helping me on this!

thanks.
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39930338
Upgrading DB2 is a lot easier than migrating.
0
 
LVL 1

Author Comment

by:marrowyung
ID: 39932268
Ahah. We will have a the last application as a fresh install on top of the MS SQL server, then use the export feature of the application to export all data to the CSV file and the reimport from the new version !
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 72
Performance issue while iterating with streams 5 39
network + 7 73
countHi2 challenge 7 44
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now