JVM Performance

Hello all,
There is strange behaviour of JVM when I tested it in following way.
I created two identical classes which are simply echoing the given parameter:
     public class Echo1 {
          public int echo(int a){
               return a;
     public class Echo2 {
          public int echo(int a){
               return a;
Then I uses these classes in a Main method in order to test:
     public class TEst {
          public static void main(String[] args) throws InterruptedException {
               int count = 100000000;
               //new Echo2()
               long start = System.currentTimeMillis();          
               for(int i=0; i<count; i++){
                    (new Echo1()).echo(1111);
               long stop = System.currentTimeMillis();          
               System.out.println("-- Elapsed Time for echo1: " + (stop - start));     
               start = System.currentTimeMillis();               
               for(int i=0; i<count; i++){
                    (new Echo2()).echo(2222);
               stop = System.currentTimeMillis();          
               System.out.println("-- Elapsed Time for echo2: " + (stop - start));          
When you run these codes, you can see these lines:
-- Elapsed Time for echo1: 640
-- Elapsed Time for echo2: 10854
But when you lift the comment of "new Echo2()" coming just after the line "int count = 100000000;"
you see totally different results for echo2:
-- Elapsed Time for echo1: 634
-- Elapsed Time for echo2: 507
My question is why the performance of jvm is increasing when i add a simple line that isnt used at top?
Or why is the performance of echo2 is too bad in first run?
Thanks
Ayd&#305;n Karaman

Note: This thread was originally posted in the [Java Virtual Machine (JVM)|http://forums.sun.com/forum.jspa?forumID=37] forum, but moved to this forum for closer topic alignment.

Similar Messages

  • JVM performance in case of JVM memory usage is high

    Hi All
         Here is some query about JVM performance in case of JVM memory usage is high.
         I have a server of 16GB. For JVM 12GB and for OS 4GB.
         Let say, My Application creating many Unnecessary Objects and consumes very high memory.
         Also, there is a gaurenty that limit of memory is it never exceed 2GB.
         No, in worst scenario memory used by JVM is 2GB.Ok.
         I have free memory available for JVM is 10GB(16GB - 2GB - 4GB(any OS memory usage)).
         Now, for any Application processing I have 10GB.
         So, does it affect application processing for which I have 10GB.
         I mean does JVM performance decreses in high JVM memory usage even I have occupied more memory to JVM.

    Hi All
         Here is some query about JVM performance in case of JVM memory usage is high.
         I have a server of 16GB. For JVM 12GB and for OS 4GB.
         Let say, My Application creating many Unnecessary Objects and consumes very high memory.
         Also, there is a gaurenty that limit of memory is it never exceed 2GB.
         No, in worst scenario memory used by JVM is 2GB.Ok.
         I have free memory available for JVM is 10GB(16GB - 2GB - 4GB(any OS memory usage)).
         Now, for any Application processing I have 10GB.
         So, does it affect application processing for which I have 10GB.
         I mean does JVM performance decreses in high JVM memory usage even I have occupied more memory to JVM.

  • Sun JVM Performance Issue in Sun Solaris 10 (SPARC)

    Hi,
    Issue : Performance issue after the migration of a Java application from IBM-AIX 5 to Sun Solaris 10 (SPARC)
    I am facing performance issue after the migration of a Java application from IBM-AIX 5.3 to Sun Solaris 10 (SPARC).
     Normally the application takes less than 1 hour to complete the process in AIX, but after migration in Solaris the application is taking 4+ hours.
    The Java version of IBM AIX is ,
    java version "1.5.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build pap32dev-20051104)
    IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223-20051103 (JIT enabled)
    The Java version of Solaris 10 is,
    Java(TM) Platform, Standard Edition for Business (build 1.5.0_17-b04)
    Java HotSpot(TM) Server VM (build 1.5.0_17-b04, mixed mode)
    Description of Application
    The application merges 2 XML files of size 300 MB each using DOM Parser and generates flat file according to certain business logic.No remote files are using for the file generation. There are two folders and around 200 XML file in each folders of similar names. The application loads 2 similar XML file at a time from each folder and Processes. Same way, the application processes all the 200 XML file pairs using loop.
    The JVM Parameters are given below.
    /usr/java5/bin/java -cp $CLASSPATH -Xms3072m -Xmx3072M com.db.mcc.creditderiv.GCDXMLTransProc
    Here the extended swap memory in AIX is 3072 (3GB). After copying the same tode to Solaris, the
    application started throwing java.lang.OutofMemoryError. So that we have increased the swap memory up to 12 GB.
    Since 32bit Java allows maximum 4 GB extended memory we started using 64 Bit Java in Solaris using -d64 argument.
    The Current JVM Parameter in Solaris is given below.
    java -d64 -cp $CLASSPATH -Xms8192m -Xmx12288m com.db.mcc.creditderiv.GCDXMLTransProc ( 64 GB Swap Memory is available in the System)
    We have tried the following options
    1.       Extended heap size up to 12 GB using -xms and -xmx parameters and tried multiple -XX options. Earlier the application was working fine in AIX with 3.5 GB extended heap size. ( 64 GB Swap Memory is available in the System)
    2.       Downloaded and installed the Solaris SPARC Patches from the website,
         http://java.sun.com/javase/downloads/index_jdk5.jsp
    4.   Downloaded and installed XML and XSLT patch from sun website
    5.       Tried to run the Java in server mode using -server option.

    A 64 bit VM is not necessarily faster than a 32 bit one. I remember at least on suggestion that it could be slower.
    Make sure you use the -server option.
    As a guess IBM isn't necessarily a slouch when it comes to Java. It might simply be that their VM was faster. Could have used a different dom library as well.
    Could be an environment problem of course.
    Profiling the application and the machine as well might provide information.

  • JVM performance slowed down after

    Hello all,
    My java application is heavily multithreaded and its supposed to run as a 24/7 service. Its supposed to collect SMS from different servers, store in memory/flat-files and send them to clients.
    The application has been running for the past 6 days and
    the JVM has slowed down considerably. (performance has gone down)
    Initially the app used to receive/send arnd 50 SMS per second and now it process aroubd 20-25 SMS per second.
    I've been using Your kit profiler to profile my app.
    The maximum heap I allocated was 500MB; the alloted Heap shown in the
    profiler is 95MB and the used Heap is 65MB
    The CPU usage looks fairly stable,i.e. it does go up when SMS comes in
    and i/o operations takes place and goes to 0% when no process is being done.
    memory usage also looks fairly stable.
    (No explicit memory leaks)
    The application has over 133 threads and that stays the same as per
    the profiler tool kit.
    Also in my application I have a maintainance phase at 23:00 hours during which i do some cleaning work like
    -deleting of expired SMS from memory
    -deleting old log files
    -deleteing other flat files
    -and finally I explicitly call the garbage collector
    What should I look in - to maintain the performance, should I not explicitly call
    the GC and let JVM do it on its own? or is it beacause the heap space has become fragmented? - I do make a lots of read/writes from/to the objects stored in Heap.
    I also make around 160,000+ read/write from/to flat files in the hard disk.
    Could this cause the JVM to slow down?
    Any suggestion on this will be great.

    Initially the app used to receive/send arnd 50 SMS
    per second and now it process aroubd 20-25 SMS per
    second.
    I've been using Your kit profiler to profile myapp.
    Does it have CPU profiling? If yes, then you can look
    at where the time's being spent when processing a
    message.
    It does have a CPU profiling graph, but there is nothing much i can infer from it, I can see the graph peaking to 60-80% CPU usage when SMS are comming in (i.e. SMS is received, stored in memory & a copy is also put in the flat file - which is a read/write I/O operation, so I would defenitely expect the CPU to peak up); this peaking up would normally happen between 6-9am when lots of SMS come it to my app. The rest of the time (in the afternoon & evening) CPU is 0% ; so I can defenitely rule ot memory leak right?
    its difficult to find out the time taken to process every message; the rough estimate I got from the log file is 50SMS / Sec. i.e. 50SMS receievd via TCP/IP; then store it in flat file & memory and also deliver it across to a client via socket; get a response back; change some status in memory and also in the flat file; this count of 50 has defenitely dropped to 25-30 in 6 days.
    >
    The maximum heap I allocated was 500MB; thealloted
    Heap shown in the profiler is 95MB and the usedHeap is 65MB
    So not a memory problem.
    The CPU usage looks fairly stable,i.e. it does goup
    when SMS comes in and i/o operations takes place
    and goes to 0% when no process is being done.So not a background thread that's run amok
    (probably).
    The application has over 133 threads and thatstays
    the same as per the profiler tool kit.You could be running into contention for a shared
    resource. This will show up in the CPU profiler, or
    you can get a "quick and dirty" report by hitting
    Ctrl-\ in the window where the JVM is running (or, if
    on Unix, sending SIGQUIT to the JVM process). This
    will send a thread dump to the console. Look for a
    lot of threads "wait"ing on some object, then look
    for the thread that holds that object.
    You are talking of possible dead-locks right? thats something i@ve go to llok into; the profiler does lists ot a list of possible thread-deadlocks. but all of them are purposefully made into TIMED_WAITING ; would that cause the performance to drop?
    >
    What should I look in - to maintain theperformance,
    should I not explicitly call the GC and let JVM doit on its own?
    Never call GC directly. The JVM will do it when
    necessary. Plus, you don't appear to have a memory
    issue.
    Yep, would change that and avoid calling GC directly.
    >
    I also make around 160,000+ read/write from/toflat
    files in the hard disk. Could this cause the JVM toslow down?
    Ahh ... flat files in a single directory? A lot of
    files in one directory will definitely slow things
    down, especially if you're opening them for every
    read and write: the OS has to scan the entire
    directory to find the file.Nothing much I can do there.
    >
    Does performance improve after your nightly cleanup?
    If yes, and you're removing old files, then this is
    an indication of the problem.I'll look into the logs to see if there is any increase in performance after GC and clome back

  • JVM Performance Tuning

    Hi,
    I am a weblogic Admin
    when tuning a performance Env.. JVM parameters becomes the backbone and the following questions has to be clarified.
    1) What could be the maximum heap size can be allocated to process in java1.5
    2) which process will give good performance (a) -XMs512m -Xmx512m / (b) -XMs512m -Xmx1024m
    3) Is it better to start a process in 32-bit or 64-bit mode
    4) what is the major difference between IBM-JVM and Sun Hotspot JVM
    Can anyone please provide your input on this.

    Jaque_Anto wrote:
    when tuning a performance Env.. JVM parameters becomes the backbone and the following questions has to be clarified.
    1) What could be the maximum heap size can be allocated to process in java1.5 Solaris? Linux? 64-bit OS?
    2) which process will give good performance (a) -XMs512m -Xmx512m / (b) -XMs512m -Xmx1024mIf the process will never need more than 512m of heap there is no difference,
    if the process needs to grow the heap that will have an impact while the heap is being increased.
    3) Is it better to start a process in 32-bit or 64-bit modeI guess that means you are running Solaris 64-bit.
    You need to run 64-bit Java to allocate heap larger than 4GB.
    4) what is the major difference between IBM-JVM and Sun Hotspot JVMToo open-ended to answer. Try a search engine.

  • How to troubleshoot JVM performance issues

    We recently had a performance issue with our application running on Java 1.4.2 on Windows where the CPU utilization was extremely high. Using the +PrintClassHistogram option I was able to determine that a char array was utilizing more than 500 megabytes of memory.
    My question is, is there another option I can include or process I can follow that would help me determine which object was creating this array?
    I am not a Java programmer so I apologize if this is elementary question or if I posted this in the wrong forum. I am the SA they call when the application is not running correctly. I have been reading this forum and the manuals trying to find something that would assist me. The developers will fix the problem after I pinpoint where the problem is.
    We do not have any type of JVM profiler so I am trying to troubleshoot this issue with thread dumps and JVM options. My assumption is that if a profiler can retrieve the information I should be able to. Is this a correct assumption?
    Lastly, if we were to purchase a profiler does anyone have a recommendation on which one to use? Our latest version of the application utilizes Java 5 so we would need something that would work with both versions of Java if possible.
    Any assistance or recommendations anyone could provide would be greatly appreciated.

    unixmon wrote:
    We recently had a performance issue with our application running on Java 1.4.2 on Windows where the CPU utilization was extremely high. Using the +PrintClassHistogram option I was able to determine that a char array was utilizing more than 500 megabytes of memory.
    My question is, is there another option I can include or process I can follow that would help me determine which object was creating this array?
    I am not a Java programmer so I apologize if this is elementary question or if I posted this in the wrong forum. I am the SA they call when the application is not running correctly. I have been reading this forum and the manuals trying to find something that would assist me. The developers will fix the problem after I pinpoint where the problem is.
    This is a management problem. If you have a performance problem then you should be calling the developers and telling them to figure it out and that they need to fix it. You certainly shouldn't be looking at code or profilers.
    Unless you have plenty of time on your hands and your goal is to become a developer.
    But regardless...
    Buying a profiler is an option but if you go that route then to figure out a solution you will be a java programmer even if that isn't your title.
    You should however figure out how to simulate load on the server, even with a profiler. There are tools that allow you to send things like http requests, web service requests, etc. Simulating load is a good idea even without a profiler. It allows you to estimate future system needs dependent upon future company growth.
    Note that profiling really slows down an application so an app that can handle 10 requests a second might only be able to do 1 a second or less while being profiled.

  • JVM performance evaluation

    I'm currently working on a project to evaluate the performance of different JVMs on the Itanium 2 platform under Linux. The main idea is to evaluate the performance of WebLogic application server using different JVMs on the forementioned platform.
    The problem I'm facing now is how to do this so that I get valid and accurate results. Does anyone know how to do this? Is it a good idea to use the benchmarks by SPEC? Which of them (SPECjbb2000, SPECjAppServer2002)?
    Thanks for the help.

    I'm currently working on a project to evaluate the
    performance of different JVMs on the Itanium 2
    platform under Linux. The main idea is to evaluate the
    performance of WebLogic application server using
    different JVMs on the forementioned platform.
    The problem I'm facing now is how to do this so that I
    get valid and accurate results. Does anyone know how
    to do this? Is it a good idea to use the benchmarks by
    SPEC? Which of them (SPECjbb2000,
    SPECjAppServer2002)?
    Thanks for the help.
    Its a good idea to go by the 'benchmark', otherwise you need to do the following.
    1. Set up a test bed consisting of various machines loaded with linux from diffrent vendors such as redhat, mandrake etc
    2. Install JVM from diffrent vendors like Sun, IBM, x, y ...
    3. Launch weblogic on those JVM using diffrent options in -mx360m -msxxxm, -mixed, -server as is required. (check for java -X options or jvm.cfg)
    4. If you have a good chunk of web application source, you can try compiling using -g option, which adds debugging information to the class files and thus grows the size of class file. the idea is to get large class files to stress out the JVM.
    5. Identify a substatially large web app/testsuite and do a load test on it. (*or* become a SUN licensee and get a j2ee JCK)...
    This was something that we did couple of months(>12) ago, There might be better solution today.
    SA

  • JVM performance profiling tool

    Hello,
    I wonder if there are any tools available out there for profiling a Java program running inside Oracle8i. A tool that measures in what methods execution time has been spent (how much time), how many instances of different objects have been created, heap size etc etc. I've been using OptimizeIt for standalone applications, but I don't know what to use for JServer inside 8i.
    Help !!!
    /Patrik

    Have you looked at JDeveloper? It has a set of execution profile and memory profile tools. It also supports debugging in the database for both PL/SQL and Java stored procedures.

  • Performance of the J2EE server for BI 70

    Hi
    We currently are running BI 70 on as 20GB(memory in *BASE), 1.5 CPU (power 6) system.
    We have close to 100 users on the system and primarliy use the excel based Bex analyzer for reporting,
    We want to start using the BI-Java stack for web based reporting, but right now its kind of a little slow, esp going in their the first time after the system restarts..( which is kind of understable..)..and even after then...
    We have already implemneted these notes for performance:
    Note 990892 - iSeries Java properties in SAP system environment
    Note 717376 - iSeries VM Settings for SAP WebAS Java (IBM Classic JVM)
    and are noticing little improvement...but still not as good as we would like it to be...
    The question we have in mind is if:
    we should start thinking about running the Java server in a separate memory pool? Right now
    the "SERVER0" job is running in *BASE...same as where our ABAP stack is running...We only have two memory pools on the system(machine and *Base)
    Which configuration is better in terms of performance, for both ABAP and JAVA? We do not want the ABAP performance to go down...( faulting rates right now is less than 100/s...but goes up when we run BI-JAVA)
    Running both ABAP and JAVA in the same (one big HUGE) memory pool
    OR
    Spliiiting up the *BASE and allocating maybe like 5- 5.5 GB to another pool and run the J2EE in that seperate memory pool, as mentioned in one of the SAP notes??
    Thanks for all your suggestions...
    Sap ques

    Hi,
    As pointed out in previous posts, moving to V6.1 and IT4J is going to result in the biggest performance improvement.  However, since you will not be moving to V6.1 anytime soon there are some other JVM tuning and configurations that can be done to improve performance of Classic JVM.
    First, as specified in earlier posts, you will want to run your Java systems in their own memory pool, regardless of whether they are standalone systems or dual stack systems.  The next thing you are going to want to look at is the JVM heap settings.  You will want to adjust your Java heap settings based on your actual workload.  The recommended default settings are not ideal under every situation, so it is best tune and configure the JVM based on analysis of the JVM from running the workload.  Most Classic JVM performance issues are a result of Xmx and Xms not being properly set for the workload.
    There is some fairly straight forward analysis that can be performed in order to optimally tune your JVM.  More information can be found at http://www-03.ibm.com/systems/i/advantages/sapj2ee/index.html.  To start, you should download from the website, the SAP NetWeaver Java on IBM i5/OS Redpaper and the "Getting the Most from Your SAP Application Server on IBM i" presentation.
    Regards,
    Kolby

  • How may one increase JVM/Java Stored Procedure Perfomance?

    Hi all,
    my question: How can one increase the performance of the Oracle JVM, especially of Java Stored Procedures?
    I ask this because I did some performance analysis (and was horrified :):
    I have a static Java method that'll need an average 15 ms to return - when executed locally.
    The same code, uploaded to an Oracle10g instance and published as Java Stored Procedure will take awful *925 ms*.
    I measured both times from within the method as shown below:
    public class JSProc {
    public static void doSomething() {
    long start = System.currentTimeMillis();
    // now comes the '15 ms'-code
    long time = System.currentTimeMillis() - start;
    That way, I'm not including any call spec overhead, network communication or whatever into the 925 ms. All in all the above procedure call will take about 1200 to 1500 ms until it returns to the client...
    The hardware: both client/server computers have the same hardware, both use the JDK provided with the latest Oracle10g release; single difference: client is Win2K, server is Linux.
    I would be immensely grateful for your suggestions concerning the possibilities to increase the JVM performance...
    Greetings,
    Sam

    As Avi suggested, subsequent calls of the procedure within the same session will reduce the execution time down to 40 ms in my testing environment.
    But that doesn't change anything for the 'first call' - when I start a new client program that opens a new connection, the Java Stored Proc will again need about a second to return.
    I wrote the procedure now in PL/SQL - it will return in less than 30 ms, subsequent calls will return in less than a ms. Guess what I'll use :)
    I played around with the JAVA* configuration params, but, as expected, that doesn't change anything in terms of performance. According to documentation, it will only affect the amount of classes I can load into the server.
    I just read that Oracle creates a new "little" JVM for every session, and I imagine that there's lot of method intercepting and things (the ominous AOP-code) to ensure transaction security.
    That's why I come to the conclusion that I won't use Java Stored Procedures for classical "connect, execute, disconnect" client-server applications. It's like full braking on the freeway :)

  • Extremely poor Java performance

    I've been experiencing particularly bad performance from Java applications lately, seemingly out of nowhere. I'm seeing a noticable lag when performing operations where there previously were none, and longer operations are taking painfully long now. This is in an application that is manipulating binary files with a Swing GUI.
    I updated to the latest version of the JRE (1.5.0_07) and it didn't help. Are there any oddball things I should be looking for, or things to change that might improve my performance?

    Perhaps you are dealing with larger and larger data files?
    Or the machine has fewer free memory due to other apps running?
    The symptom you describe (of sudden slow down,
    and noticeable lags) could be when the JVM performs
    garbage collection to cope with reduced memory.
    One thing you might want to observe is looking
    at the process size (Use the "top" command in UNIX,
    or use the process explorer on Windows).
    Another thing you might want to try is to run your program
    with profiling option turned on, so that you can see
    which method/class is taking most of the time.

  • Jvm-java virtual machine

    Hai iam new to this forum and as well i just started to learn java iwant to know in brief about JVM
    i think it may be silly question but as i am bigginer to java kindly expect reply

    georgemc wrote:
    faustofrancis wrote:
    A Java Virtual Machine (JVM) is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and scripts. The model used by a JVM accepts a form of computer intermediate language commonly referred to as Java bytecode. This language conceptually represents the instruction set of a stack-oriented, capability architecture.
    Java Virtual Machines operate on Java bytecode, which is normally (but not necessarily) generated from Java source code; a JVM can also be used to implement programming languages other than Java. For example, Ada source code can be compiled to Java bytecode, which may then be executed by a JVM. JVMs can also be released by other companies besides Sun (the developer of Java) -- JVMs using the "Java" trademark may be developed by other companies as long as they adhere to the JVM specification published by Sun (and related contractual obligations).
    The JVM is a crucial component of the Java Platform. Because JVMs are available for many hardware and software platforms, Java can be both middleware and a platform in its own right &#151; hence the expression "write once, run anywhere." The use of the same bytecode for all platforms allows Java to be described as "compile once, run anywhere", as opposed to "write once, compile anywhere", which describes cross-platform compiled languages. The JVM also enables such unique features as Automated Exception Handling which provides 'root-cause' debugging information for every software error (exception) independent of the source code.
    The JVM is distributed along with a set of standard class libraries which implement the Java API (Application Programming Interface). The virtual machine and API have to be consistent with each other[dubious &#150; discuss] and are therefore bundled together as the Java Runtime Environment.
    Execution environment
    Programs intended to run on a JVM must be compiled into a standardized portable binary format, which typically comes in the form of .class files. A program may consist of many classes in different files. For easier distribution of large programs, multiple class files may be packaged together in a .jar file (short for Java archive).
    The JVM runtime executes .class or .jar files, emulating the JVM instruction set by interpreting it, or using a just-in-time compiler (JIT) such as Sun's HotSpot. JIT compiling, not interpreting, is used in most JVMs today to achieve greater speed. Ahead-of-time compilers that enable the developer to precompile class files into native code for a particular platform also exist.
    Like most virtual machines, the Java Virtual Machine has a stack-based architecture.
    Although the JVM was primarily aimed at running compiled Java programs, other languages can now run on top of it[1], such as:
    * Ruby, with JRuby
    * JavaScript, with Rhino
    * Python, with Jython
    * Common Lisp, with Armed Bear Common Lisp
    * Groovy
    * Scala
    [edit] Bytecode verifier
    A basic philosophy of Java is that it is inherently "safe" from the standpoint that no user program can "crash" the host machine or otherwise interfere inappropriately with other operations on the host machine, and that it is possible to protect certain functions and data structures belonging to "trusted" code from access or corruption by "untrusted" code executing within the same JVM. Furthermore, common programmer errors that often lead to data corruption or unpredictable behavior such as accessing off the end of an array or using an uninitialized pointer are not allowed to occur. Several features of Java combine to provide this safety, including the class model, the garbage-collected heap, and the verifier.
    The JVM verifies all bytecode before it is executed. This verification consists primarily of three types of checks:
    * Branches are always to valid locations
    * Data is always initialized and references are always type-safe
    * Access to "private" or "package private" data and methods is rigidly controlled.
    The first two of these checks take place primarily during the "verification" step which occurs when a class is loaded and made eligible for use. The third is primarily performed dynamically, when data items or methods of a class are first accessed by another class.
    The verifier permits only some bytecode sequences in valid programs, e.g. a jump (branch) instruction can only target an instruction within the same function or method. Because of this, the fact that JVM is a stack architecture does not imply a speed penalty for emulation on register-based architectures when using a JIT compiler. In the face of the code-verified JVM architecture, it makes no difference to a JIT compiler whether it gets named imaginary registers or imaginary stack positions that need to be allocated to the target architecture's registers. In fact, code verification makes the JVM different from a classic stack architecture whose efficient emulation with a JIT compiler is more complicated and typically carried out by a slower interpreter.
    Code verification also ensures that arbitrary bit patterns cannot get used as an address. Memory protection is achieved without the need for a MMU. Thus, JVM is an efficient way of getting memory protection on simple architectures that lack an MMU. This is analogous to managed code in Microsoft's .NET CLR, and conceptually similar to capability architectures such as the Plessey 250, and IBM System/38.
    [edit] Bytecode instructions
    Main article: Java bytecode
    The JVM has instructions for the following groups of tasks:
    * Load and store
    * Arithmetic
    * Type conversion
    * Object creation and manipulation
    * Operand stack management (push / pop)
    * Control transfer (branching)
    * Method invocation and return
    * Throwing exceptions
    * Monitor-based concurrency
    The aim is binary compatibility. Each particular host operating system needs its own implementation of the JVM and runtime. These JVMs interpret the byte code semantically the same way, but the actual implementation may be different. More complicated than just the emulation of bytecode is compatible and efficient implementation of the Java core API which has to be mapped to each host operating system.
    [edit] Secure execution of remote code
    A virtual machine architecture allows very fine-grained control over the actions that code within the machine is permitted to take. This is designed to allow safe execution of untrusted code from remote sources, a model used by Java applets. Applets run within a VM incorporated into a user's browser, executing code downloaded from a remote HTTP server. The remote code runs in a restricted "sandbox", which is designed to protect the user from misbehaving or malicious code. Publishers can purchase a certificate with which to digitally sign applets as "safe", giving them permission to ask the user to break out of the sandbox and access the local file system and network...
    [edit] C to bytecode compilers
    From the point of view of a compiler Java bytecode is just another processor with an instruction set for which code can be generated. The JVM was originally designed to execute programs written in the Java language. However, the JVM provides an execution environment in the form of a bytecode instruction set and a runtime system that is general enough that it can be used as the target for compilers of other languages.
    Because of its close association with Java the JVM performs the runtime checks mandated by the Java specification. This can make it technically difficult to translate C code (which is much more lax with regard to runtime checking) to the JVM and expect it to run without issuing any warnings.
    Compilers targeting many different languages, including Ada and COBOL, have been written.
    [edit] Licensing
    Starting with J2SE 5.0, changes to the JVM specification have been developed under the Java Community Process as JSR 924[2]. As of 2006, changes to specification to support changes proposed to the class file format (JSR 202[3]) are being done as a maintenance release of JSR 924. The specification for the JVM is published in book form,[4] known as "blue book". The preface states:
    We intend that this specification should sufficiently document the Java Virtual Machine to make possible compatible clean-room implementations. Sun provides tests which verify the proper operation of implementations of the Java Virtual Machine.
    Sun's JVM is called HotSpot. Clean-room Java implementations include Kaffe and IBM J9. Sun retains control over the Java trademark, which it uses to certify implementation suites as fully compatible with Sun's specification.
    [edit] See also
    * HotSpot, Sun's Virtual Machine
    * Da Vinci Machine, a starting Sun project aiming to prototype the extension of the JVM to add support for dynamic languages.
    * List of Java virtual machines
    * Automated Exception Handling
    * Common Language Runtime
    * Parrot virtual machine
    * Java bytecode
    * Class (file format)
    * Java performance
    * List of compilers
    [edit] Notes
    1. ^ Tolksdorf, Robert (2005). Languages for the Java VM. Retrieved on 2008-04-23.
    2. ^ JSR 924 &#150; Specifies changes to the JVM specification starting with J2SE 5.0
    3. ^ JSR 202 &#150; Specifies a number of changes to the class file format
    4. ^ The Java Virtual Machine Specification (the first and second editions are also available online)
    [edit] References
    * Clarifications and Amendments to the Java Virtual Machine Specification, Second Edition includes list of changes to be made to support J2SE 5.0 and JSR 45
    * JSR 45 &#150; Specifies changes to the class file format to support source-level debugging of languages such as JSP and SQLJ that are translated to Java
    [edit] External links
    * The Java Virtual Machine Specification
    * Java-Virtual-Machine.net - All about Java Virtual Machines!
    * List of languages which compile to the Java virtual machine.
    * A decade after Java arrived, there have been improvements in the runtime performance of platform-independent virtual-machine based software.
    * Kaffe.org - the Kaffe project
    * JamVM - The Jam Virtual Machine
    * The lean, mean, virtual machine - An introduction to the basic structure and functionality of the Java Virtual Machine
    * Java Glossary - installing Java useful tips for installing Java for users and developers
    * Test your Java Virtual Machine
    * A list of Java VM-s used in mobile devices
    * More Languages for the JVM
    * Sun to build virtual machine for iPhone - ComputerWorldAre you aware that Wikipedia has ripped off your post?not yet?
    Let me see if the systems work!

  • How jvm threads works on new Linux 2.6 scheduler with SMP kernell

    Hi,
    i'm using Sun JDK Java HotSpot(TM) Server VM (build 1.5.0_14-b03, mixed mode) to run tomcat,
    anyone knows How JVM threads works on new Linux 2.6 scheduler with SMP kernel?
    i ask this, because in a single processor machine the tomcat replies more fast than a dual processor machine, maybe the reason is, that SMP load balancing made for new scheduler, slow down the JVM performance for threads? there is a way to avoid this?
    reference about Linux Scheduler: http://www-128.ibm.com/developerworks/linux/library/l-scheduler/?ca=dgr-lnxw09LinuxScheduler
    bug that have "same" problem: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5038858
    thanks for any insight

    This is bug:
    6328462 Linux getCurrentThreadCpuTime() does not match with getThreadCpuTime(currentThread)
    It will be fixed in:
    - JDK 6.0 (Mustang) build b63
    - JDK 1.5.0_07 build b01
    The problem is that the HotSpot VM takes the stat info from the file'/proc/$tid/stat'
    which is incorrect on Linux kernels 2.6+ with NPTL because this file aggregates
    per-process (.vs. per-thread) usage on these kernels.
    The file '/proc/self/task/$tid/stat' still has the per-thread usage and must be used instead.
    There is also a performance bug:
    6200022: JVMTI GetCurrentThreadCpuTime slow on Linux
    This bug is about using new Linux posix compliant process clocks (2.6.10) :
    http://sources.redhat.com/ml/libc-alpha/2004-10/msg00117.html
    It is too late to fix this in Mustang but can be possible in one of the update releases.
    Thank you for posting the question!
    Serguei

  • Compiler Compliance

    Im looking for answers/references on JVM performance regarding the latest Java v6 performance benchmarks. Specifically if i compile with the Java v6 compiler setting to Java v5 compliance and running on the v6 VM what am I getting in terms of the marketed performance blow-out of the v6 VM? Does the bytecode compilation drastically make a difference?

    Installing a newer version of eclipse will solve your issue.

  • EJB client spawning threads

    We've got problems with respect to the number of EJB client threads (ExecuteThread) spawned by WebLogic in a client JVM. As the number of threads increase (~1700 in a JVM with 512Mb of memory and 2 hours of uptime), the JVM performance degrades substantially - although almost all these threads are waiting for requests, as one can see in the thread dump attached bellow.
    This problem happens in an integration scenario involving both WebLogic (8.1 and 6.1 as service providers) and webMethods Integration Server (version 6.0.1); the webMethods EJB adapter (version 1.2) acts like EJB client from the WebLogic instances, and the "EJB client spawning threads" can be detected by thread dumps extracted from the Integration Server JVM. The URL property from the wm EJB adapter has been setup as t3://server:port. The Integration Server runs with Java HotSpot(TM) Server VM (build 1.4.2 1.4.2.02-040225-19:18-PA_RISC2.0 PA2.0 (aCC_AP), mixed mode) JRE in HP-UX (11.11) environment.
    Although we couldn't reproduce this problem in a prod like environemnt, we'd identified that initially, WebLogic (weblogic.jar from WebLogic 6.1) spawns 5 ExecuteThreads plus 3 additional threads (TimeEventGenerator, SpinnerRandomSource and HighPriority TimeEventGenerator) in the first access of an EJB not matter the instance used, as well as two new threads (ExecuteThread) for each access to new WebLogic instances (different from previously accessed WebLogic instances). With weblogic.jar from the WebLogic 8.1 SP4 the behavior is slightly different: from the second instance access toward, only two new Threads (ExecuteThread in weblogic.JavaSocketReaders queue) are created.
    We have also noticed that this problem should not be reflect of context classloaders because the counter of the ExecuteThread for the default pool only increases; in case of a pool cached in separate context classloaders, we should see "duplicate" threads with the same counter (starting with 0), which is not the case.
    The questions are 1) why weblogic is spawning so much threads; 2) is there any setup/config to limit the number of WebLogic threads in the client context ?
    Excerpt from the thread dump:
    Full thread dump Java HotSpot(TM) Server VM (1.4.2 1.4.2.02-040225-19:18-PA_RISC2.0 PA2.0 (aCC_AP) mixed mode):
    "ExecuteThread: '1749' for queue: 'default'" daemon prio=10 tid=05734140 nid=4813 lwp_id=583942 in Object.wait() [0x0dfbe000..0x0dfbe4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4a5ef9f0> (a weblogic.common.internal.DynaQueue)
         at weblogic.common.internal.DynaQueue.getW(DynaQueue.java:228)
         - locked <4a5ef9f0> (a weblogic.common.internal.DynaQueue)
         at weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:252)
         at weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:233)
         at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    "ExecuteThread: '1742' for queue: 'default'" daemon prio=10 tid=04c263f0 nid=4812 lwp_id=583845 runnable [0x06449000..0x064494f0]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:281)
         - locked <4a5ee690> (a java.net.Socket)
         at weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:233)
         at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    "ExecuteThread: '1735' for queue: 'default'" daemon prio=10 tid=05733fd8 nid=4811 lwp_id=583784 in Object.wait() [0x064ca000..0x064ca4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4c40a6b8> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4c40a6b8> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "ExecuteThread: '1734' for queue: 'default'" daemon prio=10 tid=01ecd940 nid=4810 lwp_id=583783 in Object.wait() [0x0654b000..0x0654b4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4c40a728> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4c40a728> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "ExecuteThread: '1733' for queue: 'default'" daemon prio=10 tid=05733e70 nid=4806 lwp_id=583777 in Object.wait() [0x066ce000..0x066ce4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4c40a798> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4c40a798> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "ExecuteThread: '1732' for queue: 'default'" daemon prio=10 tid=01ecd7d8 nid=4801 lwp_id=583771 in Object.wait() [0x065cc000..0x065cc4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4c40a808> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4c40a808> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "ExecuteThread: '1731' for queue: 'default'" daemon prio=10 tid=05733d08 nid=4798 lwp_id=583766 in Object.wait() [0x067d0000..0x067d04f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4c40a878> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4c40a878> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    ... (cut for brevity)
    "ExecuteThread: '2' for queue: 'default'" daemon prio=10 tid=009251b8 nid=172 lwp_id=569500 in Object.wait() [0x3d61f000..0x3d61f4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4a5b4498> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4a5b4498> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "ExecuteThread: '1' for queue: 'default'" daemon prio=10 tid=00924ee8 nid=171 lwp_id=569499 in Object.wait() [0x3d6a0000..0x3d6a04f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4a5b40f0> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4a5b40f0> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "ExecuteThread: '0' for queue: 'default'" daemon prio=10 tid=00925050 nid=170 lwp_id=569498 in Object.wait() [0x3d7a2000..0x3d7a24f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <4a5b3d48> (a weblogic.kernel.ExecuteThread)
         at java.lang.Object.wait(Object.java:429)
         at weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)
         - locked <4a5b3d48> (a weblogic.kernel.ExecuteThread)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)
    "Thread-2" daemon prio=10 tid=00bec5f0 nid=18 lwp_id=569246 in Object.wait() [0x41e2e000..0x41e2e4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c14ff0> (a com.wm.app.repov4.server.RepoServer$RepoLockTimeoutMgr)
         at com.wm.app.repov4.server.RepoServer$RepoLockTimeoutMgr.run(RepoServer.java:1533)
         - locked <46c14ff0> (a com.wm.app.repov4.server.RepoServer$RepoLockTimeoutMgr)
    "Thread-1" daemon prio=10 tid=00bec488 nid=17 lwp_id=569244 in Object.wait() [0x41eaf000..0x41eaf4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c150a8> (a com.wm.driver.queue.data.DataQueue)
         at java.lang.Object.wait(Object.java:429)
         at com.wm.driver.queue.data.DataQueue.dequeue(DataQueue.java:310)
         - locked <46c150a8> (a com.wm.driver.queue.data.DataQueue)
         at com.wm.driver.queue.data.DataQueue.dequeueCommit(DataQueue.java:260)
         - locked <46c150a8> (a com.wm.driver.queue.data.DataQueue)
         at com.wm.driver.queue.data.DataQueue.dequeueCommit(DataQueue.java:254)
         - locked <46c150a8> (a com.wm.driver.queue.data.DataQueue)
         at com.wm.app.repov4.server.RepoServerBase$RepoEventManager.run(RepoServerBase.java:224)
    "Log Thread" prio=10 tid=00bec320 nid=16 lwp_id=569243 in Object.wait() [0x41f30000..0x41f304f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c15120> (a com.wm.util.sync.SimpleQueue)
         at com.wm.util.sync.SimpleQueue.deq(SimpleQueue.java:171)
         - locked <46c15120> (a com.wm.util.sync.SimpleQueue)
         at com.wm.util.sync.SimpleQueue.deq(SimpleQueue.java:126)
         - locked <46c15120> (a com.wm.util.sync.SimpleQueue)
         at com.wm.app.b2b.server.ServerLogHandler$LogThread.run(ServerLogHandler.java:268)
    "Cron Daemon" prio=10 tid=00bec1b8 nid=15 lwp_id=569241 in Object.wait() [0x41fb1000..0x41fb14f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c15190> (a java.util.Vector)
         at com.wm.util.Cron.run(Cron.java:424)
         - locked <46c15190> (a java.util.Vector)
         at java.lang.Thread.run(Thread.java:534)
    "Cron Daemon Pool2" prio=10 tid=00bec050 nid=14 lwp_id=569240 in Object.wait() [0x42032000..0x420324f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c15268> (a com.wm.util.pool.PooledThread)
         at java.lang.Object.wait(Object.java:429)
         at com.wm.util.pool.PooledThread.run(PooledThread.java:103)
         - locked <46c15268> (a com.wm.util.pool.PooledThread)
         at java.lang.Thread.run(Thread.java:534)
    "Cron Daemon Pool1" prio=10 tid=00bebee8 nid=13 lwp_id=569239 in Object.wait() [0x420b3000..0x420b34f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c152d0> (a com.wm.util.pool.PooledThread)
         at java.lang.Object.wait(Object.java:429)
         at com.wm.util.pool.PooledThread.run(PooledThread.java:103)
         - locked <46c152d0> (a com.wm.util.pool.PooledThread)
         at java.lang.Thread.run(Thread.java:534)
    "webMethods Integration Server" prio=10 tid=000870e0 nid=12 lwp_id=569238 in Object.wait() [0x42134000..0x421344f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c152f0> (a com.wm.app.b2b.server.Server)
         at java.lang.Object.wait(Object.java:429)
         at com.wm.app.b2b.server.Server.run(Server.java:353)
         - locked <46c152f0> (a com.wm.app.b2b.server.Server)
    "Signal Dispatcher" daemon prio=10 tid=00086f78 nid=7 lwp_id=569231 waiting on condition [0x00000000..0xffffffff]
    "Finalizer" daemon prio=10 tid=00086e10 nid=5 lwp_id=569229 in Object.wait() [0x4293b000..0x4293b4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c15668> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
         - locked <46c15668> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:188)
    "Reference Handler" daemon prio=10 tid=00086ca8 nid=4 lwp_id=569228 in Object.wait() [0x429bc000..0x429bc4f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c15340> (a java.lang.ref.Reference$Lock)
         at java.lang.Object.wait(Object.java:429)
         at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:120)
         - locked <46c15340> (a java.lang.ref.Reference$Lock)
    "main" prio=10 tid=00086b40 nid=1 lwp_id=569222 in Object.wait() [0x68ff3000..0x68ff24f0]
         at java.lang.Object.wait(Native Method)
         - waiting on <46c152f0> (a com.wm.app.b2b.server.Server)
         at java.lang.Thread.join(Thread.java:1001)
         - locked <46c152f0> (a com.wm.app.b2b.server.Server)
         at java.lang.Thread.join(Thread.java:1054)
         at com.wm.app.b2b.server.Server.start(Server.java:141)
         at com.wm.app.b2b.server.Main.main(Main.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.wm.proxy.Proxy.invokeStaticMethod(Proxy.java:166)
         at com.wm.app.server.ServerProxy.ServerMain_main(ServerProxy.java:77)
         at com.wm.app.server.ServerApp.start(ServerApp.java:105)
         at com.wm.app.Application.launch(Application.java:490)
         at com.wm.app.server.Main.main(Main.java:50)
    "VM Thread" prio=7 tid=000167f8 nid=3 lwp_id=569227 runnable
    "VM Periodic Task Thread" prio=8 tid=00016908 nid=11 lwp_id=569235 waiting on condition
    "Suspend Checker Thread" prio=10 tid=00016880 nid=6 lwp_id=569230 runnable

    We already opened a case. Actually, we did reproduce the problem: it happens because there is a hardware load balancing between the client and the WebLogic Server.
    As far as I know, EJB load balancing can be done only with WebLogic clusters. Could you confirm that ?

Maybe you are looking for