Threads CPU time

Hi
I have some simple test porgram:
class ThreadTest extends Thread
   private ThreadMXBean tmbean  =  ManagementFactory.getThreadMXBean();
   public ThreadTest()
       super("ReceiveThread");
   public void run()
      new MyTest();
      long time = tmbean.getCurrentThreadCpuTime();
      System.out.println("Time: " + time);
}and
public class RunTest
  public static void main(String[] args)
      int count = 0;
      while(count < 5)
          new ThreadTest().start();
         count++;
}In each thread i create object MyTest - some simple calculations, but in some cases CPU time is 0.
How is this possible? Method 'getCurrentThreadCpuTime()' returns time in nanoseconds. Is something wrong in this way of creating ThreadMXBean object or something?
Thanks for any help

Try this one it may explain your problem
import java.lang.management.*;
public class CPUTimeTest{
    public static void main(String args[]){
        long vals[] = null;
        final ThreadMXBean tbe  =  ManagementFactory.getThreadMXBean();
        try{
            vals = new long[Integer.parseInt(args[0])];
            if(tbe.isCurrentThreadCpuTimeSupported()){
                tbe.setThreadCpuTimeEnabled(true);
            else{
                 System.out.println("Function not Supported");
                 return;
         catch(RuntimeException re){
             System.out.println("Usage :java CPUTimeTest num_samples");
             return;
         for(int i =0;i<vals.length;i++){
             Thread t = new Thread(){
                 public void run(){
                     System.out.println("Time = "+tbe.getCurrentThreadCpuTime());
             t.start();
         System.out.println("Total Time = "+tbe.getCurrentThreadCpuTime());
}I got the following results
java CPUTimeTest 10
Time = 10000000
Time = 0
Time = 0
Time = 0
Time = 0
Time = 0
Time = 0
Time = 0
Time = 0
Total Time = 410000000
Time = 0
My system is a linux red hat 7.2 with pentium II 233Mhz java 1.5
I think its because you are not doing anything in those threads

Similar Messages

  • Thread CPU time: does it include the time while thread is waiting

    Hi,
    My question is regarding the getCurrentThreadCpuTime() supported by the ThreadMXBean.
    I wonder if the returned time includes the time while the thread is waiting, i.e. after the thread calls wait() and before getting a notify() or a notifyAll().
    Thanks,
    Nuha

    CPU time is intended to reflect actual time executing on a CPU. If block for a lock/wait/sleep or other blocking operation like I/O then you don't consume CPU while blocked.
    On Solaris it is implemented using gethrvtime()
    If a VM used a busy-wait for something rather than blocking (not likely with wait()) then that's consuming CPU time.

  • How to measure and control process CPU time of a java program

    Hi dudes,
    what I am trying to do is to compare 2 algorithms, with the same computation time. To measure the time, one can for example:
    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() - startTime < 10 * 1000) {
    running some code
    However, in this case System.currentTimeMillis() measures only the wall clock time, not the real process time, i.e. if the CPU is also running some other processes at the same time, the computation time measure is inaccurate.
    I learned from other post that this is not easy, but is there on earth a way to solve it? the java profiler seems to be able to monitor the process time but cannot be used to control the computation time at run time. And another thing I learned is a method Thread.getCurrentThreadCpuTime, does it measure the real thread process time or wall clock time?
    Any other suggestions? I had all my codes in java and used only single thread, running under linux.
    Thanks a lot in advance!
    Eric

    Check out:
    http://java.sun.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html
    The timing methods measure thread CPU time, not wall clock time.

  • Kernel task is hogging lots of threads and CPU time

    My Mavericks Quad Macbook Pro is getting pretty slow these days and at some point I'll have to reinstall everything I think. However I can't start that for a while as I have important projects on the go. I looked in Activity Monitor first and I can see a kernel task constantly running with no indication of what it is doing. So I opened Console and looked at the Diagnostic log. I can see a lot of lines referring to com.apple.message. Hundreds of identical lines actually. I did not have Messages running so I opened it, and sure enough that showed up in console live. However the log shows a slightly different app and a totally different UUID, which seems odd.
    Anybody understand what this is all about? See below. I opened one of the endlessly repeating items plus one that I know is from the Messages app below it.
    23/03/2015 08:28:29.242 UserEventAgent[235]: com.apple.message.domain: com.apple.usage.app_activetime
    com.apple.message.signature: universalAccessAuthWarn
    com.apple.message.signature2: com.apple.accessibility.universalAccessAuthWarn ||| 1.0 (190.1)
    com.apple.message.value: 633
    com.apple.message.value2: 0
    com.apple.message.value3: 0
    com.apple.message.value4: 0
    com.apple.message.value5: 0
    com.apple.message.value6: 0
    com.apple.message.value7: 0
    com.apple.message.result: NO
    com.apple.message.summarize: YES
    Sender_Mach_UUID: 55428B1C-9198-32BF-80EA-4731081F402E
    23/03/2015 08:44:17.426 Messages[8722]: com.apple.message.domain: com.apple.iChat.app.weeklyStats
    com.apple.message.video_chat_passed: 0
    com.apple.message.video_chat_failed: 0
    com.apple.message.video_chat_noop: 0
    com.apple.message.audio_chat_passed: 0
    com.apple.message.audio_chat_failed: 0
    com.apple.message.audio_chat_noop: 0
    com.apple.message.screen_sharing_passed: 0
    com.apple.message.screen_sharing_failed: 0
    com.apple.message.screen_sharing_noop: 0
    com.apple.message.average_message_length: 0.000000
    com.apple.message.messages_sent: 0
    com.apple.message.messages_received: 0
    com.apple.message.sms_sent: 0
    com.apple.message.sms_menu_used: User never selected SMS menu
    com.apple.message.result: pass
    com.apple.message.imessage_offered_upgrades: 0
    com.apple.message.imessage_upgrades: 0
    com.apple.message.imessage_declines: 0
    com.apple.message.imessages_sent: 0
    com.apple.message.imessages_received: 0
    Sender_Mach_UUID: 212E34A8-B310-3729-8D11-879E9985A0BD
    23/03/2015 08:44:17.427 Messages[8722]: com.apple.message.domain: com.apple.iChat.app.servicesUsedThisWeek
    com.apple.message.aim: 0
    com.apple.message.bonjour: 0
    com.apple.message.yahoo: 0
    com.apple.message.jabber: 0
    com.apple.message.google_talk: 0
    com.apple.message.imessage: 1
    com.apple.message.other: 0
    com.apple.message.result: pass
    Sender_Mach_UUID: 212E34A8-B310-3729-8D11-879E9985A0BD
    23/03/2015 08:44:32.607 Messages[8722]: com.apple.message.domain: com.apple.iChat.app.prefs
    com.apple.message.one_on_one_style: com.apple.iChat.Styles.Balloons-ShowPictures
    com.apple.message.group_style: com.apple.iChat.Styles.Balloons-ShowPictures
    com.apple.message.incoming_bg_color: Automatic
    com.apple.message.outgoing_bg_color: Automatic
    com.apple.message.incoming_font: Default 12.000000
    com.apple.message.outgoing_font: Default 12.000000
    com.apple.message.save_history: Don't Save
    Sender_Mach_UUID: 212E34A8-B310-3729-8D11-879E9985A0BD

    The kernel_task is the heart of the operating system.  It will have on the order of a 100 threads (more or less).  So when you ask the operating system to do something, like read/write a disk, do network I/O, talk to your mouse/trackpad, keyboard, monitor, etc... kernel_task is the code that is going to do that at the lowest levels.
    Also if you have installed any 3rd party drivers (kernel extensions), they are going to become part of kernel_task and the CPU time they use will be part of kernel_task.
    If you have anti-malware, Mac cleaner or memory cleaner software installed, many of these packages install drivers that then try to out-guess the kernel_task and often result in slowing down the system, interfering with the normal operation of the system, or causing kernel panics.  These kinds of packages are not recommended by long term forum contributors.
    Please provide the output from EtreCheck, which will show the 3rd party additions you have installed.
    <https://discussions.apple.com/docs/DOC-6174>

  • Thread.sleep takes a lot of CPU time!

    Hi,
    I have the run method like this:
    public void run()
    while(true)
    //some set of operations
    Thread.sleep(5*1000*60);
    The above code's performance was measured under stress test. . The sleep operation seems to take a lot of CPU time
    though ideally sleep is like a no-operation mode, meaning since no operation
    is done when a thread sleeps, it should not use any/minimal CPU time.
    But it seems to take over 30% of CPU time!
    Any ideas on why such a weird thing's happening?
    In fact, in one more similar method also, sleep is taking similar CPU
    time.

    A sleeping thread uses no CPU. Try the following, both with and without the for loop. If you see a constant high CPU usage, even when the thread is sleeping, it's probably that the CPU usage is measured as an average over the last second or several seconds, so when the tasks you're performing are intense and take a significant fraction of the time you're sleeping, the average CPU usage doesn't go down that much.
    public class Sleeper {
        public static void main(String[] args) throws Exception {
            while(true) {
                for (int ix = 0; ix < 100000000; ix++) {
                    int jx = ix * 2;
                    ix = --jx;
                Thread.sleep(5 * 1000* 60);
    }

  • Performance Degradated  Possibly due to CPU Time

    Hi Gurus,
    There is a utility in our application with which we can upload an excel sheet containing data and schedule the timing of the job, now when the job is executed, each row in the excel sheet leads to dml operations on multiple tables finally leading to generation of a transaction no. Now at the start around 100-120 transaction nos were generated which goes down drastically to around 30-35 after 6-7 hours. AWR report at the two instances shows that CPU time has decreased considerably in the 2nd case.
    I would like you experts to check the awr reports and suggest me the probable reason for the decrease in performance.
    Brief AWR Report When Performance was OK
    Snap Id Snap Time Sessions Curs/Sess
    Begin Snap: 2151 14-Dec-10 16:32:57 26 3.7
    End Snap: 2152 14-Dec-10 17:31:04 40 16.7
    Elapsed: 58.13 (mins)
    DB Time: 55.37 (mins)
    Cache Sizes
    ~~~~~~~~~~~ Begin End
    Buffer Cache: 436M 444M Std Block Size: 8K
    Shared Pool Size: 120M 120M Log Buffer: 6,968K
    Load Profile
    ~~~~~~~~~~~~ Per Second Per Transaction
    Redo size: 27,541.56 1,747.07
    Logical reads: 49,830.97 3,160.97
    Block changes: 181.79 11.53
    Physical reads: 1,270.12 80.57
    Physical writes: 2.81 0.18
    User calls: 119.95 7.61
    Parses: 200.94 12.75
    Hard parses: 29.29 1.86
    Sorts: 91.80 5.82
    Logons: 0.03 0.00
    Executes: 457.16 29.00
    Transactions: 15.76
    % Blocks changed per Read: 0.36 Recursive Call %: 96.36
    Rollback per transaction %: 0.01 Rows per Sort: 270.64
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Buffer Nowait %: 100.00 Redo NoWait %: 100.00
    Buffer Hit %: 97.45 In-memory Sort %: 100.00
    Library Hit %: 90.18 Soft Parse %: 85.42
    Execute to Parse %: 56.05 Latch Hit %: 100.00
    Parse CPU to Parse Elapsd %: 98.04 % Non-Parse CPU: 94.98
    Shared Pool Statistics Begin End
    Memory Usage %: 72.65 84.55
    % SQL with executions>1: 71.49 75.08
    % Memory for SQL w/exec>1: 84.79 85.25
    Top 5 Timed Events Avg %Total
    ~~~~~~~~~~~~~~~~~~ wait Call
    Event Waits Time (s) (ms) Time Wait Class
    CPU time 2,541 76.5
    db file scattered read 284,992 410 1 12.3 User I/O
    log file parallel write 31,188 145 5 4.4 System I/O
    TCP Socket (KGAS) 24 131 5459 3.9 Network
    log file sync 8,617 46 5 1.4 Commit
    Time Model Statistics DB/Inst: ABCTEST/abctest Snaps: 2151-2152
    -> Total time in database user-calls (DB Time): 3322.4s
    -> Statistics including the word "background" measure background process
    time, and so do not contribute to the DB time statistic
    -> Ordered by % or DB time desc, Statistic name
    Statistic Name Time (s) % of DB Time
    sql execute elapsed time 3,176.8 95.6
    DB CPU 2,541.1 76.5
    PL/SQL execution elapsed time 288.5 8.7
    parse time elapsed 278.7 8.4
    hard parse elapsed time 254.6 7.7
    PL/SQL compilation elapsed time 28.9 .9
    failed parse elapsed time 4.9 .1
    hard parse (sharing criteria) elapsed time 1.3 .0
    sequence load elapsed time 1.1 .0
    repeated bind elapsed time 1.1 .0
    connection management call elapsed time 0.7 .0
    hard parse (bind mismatch) elapsed time 0.3 .0
    DB time 3,322.4 N/A
    background elapsed time 197.1 N/A
    background cpu time 5.6 N/A
    Wait Class DB/Inst: ABCTEST/abctest Snaps: 2151-2152
    -> s - second
    -> cs - centisecond - 100th of a second
    -> ms - millisecond - 1000th of a second
    -> us - microsecond - 1000000th of a second
    -> ordered by wait time desc, waits desc
    Avg
    %Time Total Wait wait Waits
    Wait Class Waits -outs Time (s) (ms) /txn
    User I/O 292,720 .0 427 1 5.3
    System I/O 37,408 .0 190 5 0.7
    Network 272,062 .0 132 0 4.9
    Commit 8,617 .0 46 5 0.2
    Configuration 4 .0 2 593 0.0
    Application 3,212 .0 0 0 0.1
    Other 280 .4 0 0 0.0
    Concurrency 247 .0 0 0 0.0
    Wait Events DB/Inst: ABCTEST/abctest Snaps: 2151-2152
    -> s - second
    -> cs - centisecond - 100th of a second
    -> ms - millisecond - 1000th of a second
    -> us - microsecond - 1000000th of a second
    -> ordered by wait time desc, waits desc (idle events last)
    Avg
    %Time Total Wait wait Waits
    Event Waits -outs Time (s) (ms) /txn
    db file scattered read 284,992 .0 410 1 5.2
    log file parallel write 31,188 .0 145 5 0.6
    TCP Socket (KGAS) 24 .0 131 5459 0.0
    log file sync 8,617 .0 46 5 0.2
    db file parallel write 4,215 .0 29 7 0.1
    db file sequential read 7,634 .0 16 2 0.1
    control file parallel write 1,202 .0 16 13 0.0
    Streams AQ: enqueue blocked 1 .0 2 2055 0.0
    control file sequential read 795 .0 1 1 0.0
    Data file init write 48 .0 0 9 0.0
    SQL*Net message to client 266,802 .0 0 0 4.9
    log file switch completion 3 .0 0 106 0.0
    SQL*Net break/reset to clien 3,212 .0 0 0 0.1
    SQL*Net more data to client 4,789 .0 0 0 0.1
    direct path write 23 .0 0 3 0.0
    rdbms ipc reply 67 .0 0 1 0.0
    kksfbc child completion 1 100.0 0 47 0.0
    latch: shared pool 213 .0 0 0 0.0
    latch: library cache 26 .0 0 1 0.0
    log file single write 4 .0 0 7 0.0
    log file sequential read 4 .0 0 5 0.0
    db file single write 3 .0 0 5 0.0
    os thread startup 3 .0 0 4 0.0
    enq: JS - queue lock 4 .0 0 3 0.0
    LGWR wait for redo copy 207 .0 0 0 0.0
    library cache pin 1 .0 0 6 0.0
    SQL*Net more data from clien 447 .0 0 0 0.0
    library cache load lock 1 .0 0 2 0.0
    latch: cache buffers chains 1 .0 0 0 0.0
    latch: row cache objects 1 .0 0 0 0.0
    direct path read 20 .0 0 0 0.0
    latch free 1 .0 0 0 0.0
    cursor: mutex S 1 .0 0 0 0.0
    SQL*Net message from client 266,789 .0 64,143 240 4.9
    Streams AQ: qmn slave idle w 124 .0 3,488 28127 0.0
    Streams AQ: qmn coordinator 257 51.4 3,488 13571 0.0
    virtual circuit status 116 100.0 3,480 29999 0.0
    Streams AQ: waiting for time 5 60.0 745 148902 0.0
    jobq slave wait 52 96.2 155 2987 0.0
    PL/SQL lock timer 16 100.0 16 995 0.0
    class slave wait 1 100.0 5 4995 0.0
    Background Wait Events DB/Inst: ABCTEST/abctest Snaps: 2151-2152
    -> ordered by wait time desc, waits desc (idle events last)
    Avg
    %Time Total Wait wait Waits
    Event Waits -outs Time (s) (ms) /txn
    log file parallel write 31,188 .0 145 5 0.6
    db file parallel write 4,215 .0 29 7 0.1
    control file parallel write 1,193 .0 16 13 0.0
    Streams AQ: enqueue blocked 1 .0 2 2055 0.0
    control file sequential read 691 .0 0 1 0.0
    db file sequential read 66 .0 0 5 0.0
    direct path write 23 .0 0 3 0.0
    log file single write 4 .0 0 7 0.0
    log file sequential read 4 .0 0 5 0.0
    events in waitclass Other 211 .0 0 0 0.0
    os thread startup 3 .0 0 4 0.0
    db file scattered read 1 .0 0 13 0.0
    latch: shared pool 5 .0 0 0 0.0
    direct path read 20 .0 0 0 0.0
    latch: library cache 1 .0 0 0 0.0
    rdbms ipc message 34,411 32.3 30,621 890 0.6
    Streams AQ: qmn slave idle w 124 .0 3,488 28127 0.0
    Streams AQ: qmn coordinator 257 51.4 3,488 13571 0.0
    pmon timer 1,235 100.0 3,486 2822 0.0
    smon timer 19 47.4 3,460 182099 0.0
    Streams AQ: waiting for time 5 60.0 745 148902 0.0
    class slave wait 1 100.0 5 4995 0.0
    Operating System Statistics DB/Inst: ABCTEST/abctest Snaps: 2151-2152
    Statistic Total
    AVG_BUSY_TIME 81,951
    AVG_IDLE_TIME 266,698
    AVG_SYS_TIME 10,482
    AVG_USER_TIME 71,389
    BUSY_TIME 328,163
    IDLE_TIME 1,067,144
    SYS_TIME 42,281
    USER_TIME 285,882
    RSRC_MGR_CPU_WAIT_TIME 0
    VM_IN_BYTES 1,625,600,000
    VM_OUT_BYTES 145,162,240
    PHYSICAL_MEMORY_BYTES 3,755,851,776
    NUM_CPUS 4
    NUM_CPU_CORES 1
    Brief AWR Report When Performance* Deteriorated.
    Snap Id Snap Time Sessions Curs/Sess
    Begin Snap: 2168 15-Dec-10 08:31:05 32 18.4
    End Snap: 2169 15-Dec-10 09:30:56 32 18.3
    Elapsed: 59.85 (mins)
    DB Time: 17.97 (mins)
    Cache Sizes
    ~~~~~~~~~~~ Begin End
    Buffer Cache: 448M 448M Std Block Size: 8K
    Shared Pool Size: 116M 116M Log Buffer: 6,968K
    Load Profile
    ~~~~~~~~~~~~ Per Second Per Transaction
    Redo size: 10,503.58 1,792.02
    Logical reads: 17,583.21 2,999.87
    Block changes: 68.60 11.70
    Physical reads: 472.37 80.59
    Physical writes: 1.54 0.26
    User calls: 39.12 6.67
    Parses: 53.32 9.10
    Hard parses: 7.99 1.36
    Sorts: 13.84 2.36
    Logons: 0.00 0.00
    Executes: 130.30 22.23
    Transactions: 5.86
    % Blocks changed per Read: 0.39 Recursive Call %: 94.39
    Rollback per transaction %: 0.00 Rows per Sort: 691.64
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Buffer Nowait %: 100.00 Redo NoWait %: 100.00
    Buffer Hit %: 97.31 In-memory Sort %: 100.00
    Library Hit %: 92.41 Soft Parse %: 85.02
    Execute to Parse %: 59.08 Latch Hit %: 100.00
    Parse CPU to Parse Elapsd %: 100.28 % Non-Parse CPU: 95.35
    Shared Pool Statistics Begin End
    Memory Usage %: 88.40 88.48
    % SQL with executions>1: 76.15 80.48
    % Memory for SQL w/exec>1: 86.82 88.85
    Top 5 Timed Events Avg %Total
    ~~~~~~~~~~~~~~~~~~ wait Call
    Event Waits Time (s) (ms) Time Wait Class
    CPU time 918 85.1
    db file scattered read 113,003 127 1 11.7 User I/O
    log file parallel write 11,978 52 4 4.8 System I/O
    db file parallel write 3,089 16 5 1.4 System I/O
    control file parallel write 1,217 15 13 1.4 System I/O
    Time Model Statistics DB/Inst: ABCTEST/abctest Snaps: 2168-2169
    -> Total time in database user-calls (DB Time): 1078.1s
    -> Statistics including the word "background" measure background process
    time, and so do not contribute to the DB time statistic
    -> Ordered by % or DB time desc, Statistic name
    Statistic Name Time (s) % of DB Time
    sql execute elapsed time 1,032.1 95.7
    DB CPU 917.6 85.1
    parse time elapsed 71.8 6.7
    hard parse elapsed time 52.4 4.9
    PL/SQL execution elapsed time 7.2 .7
    PL/SQL compilation elapsed time 6.2 .6
    failed parse elapsed time 1.8 .2
    sequence load elapsed time 0.4 .0
    repeated bind elapsed time 0.3 .0
    connection management call elapsed time 0.1 .0
    hard parse (sharing criteria) elapsed time 0.0 .0
    hard parse (bind mismatch) elapsed time 0.0 .0
    DB time 1,078.1 N/A
    background elapsed time 89.4 N/A
    background cpu time 6.4 N/A
    Wait Class DB/Inst: ABCTEST/abctest Snaps: 2168-2169
    -> s - second
    -> cs - centisecond - 100th of a second
    -> ms - millisecond - 1000th of a second
    -> us - microsecond - 1000000th of a second
    -> ordered by wait time desc, waits desc
    Avg
    %Time Total Wait wait Waits
    Wait Class Waits -outs Time (s) (ms) /txn
    User I/O 122,810 .0 133 1 5.8
    System I/O 17,013 .0 83 5 0.8
    Commit 3,129 .0 14 5 0.1
    Network 90,186 .0 0 0 4.3
    Configuration 2 .0 0 63 0.0
    Application 1,120 .0 0 0 0.1
    Other 112 .0 0 0 0.0
    Concurrency 2 .0 0 6 0.0
    Wait Events DB/Inst: ABCTEST/abctest Snaps: 2168-2169
    -> s - second
    -> cs - centisecond - 100th of a second
    -> ms - millisecond - 1000th of a second
    -> us - microsecond - 1000000th of a second
    -> ordered by wait time desc, waits desc (idle events last)
    Avg
    %Time Total Wait wait Waits
    Event Waits -outs Time (s) (ms) /txn
    db file scattered read 113,003 .0 127 1 5.4
    log file parallel write 11,978 .0 52 4 0.6
    db file parallel write 3,089 .0 16 5 0.1
    control file parallel write 1,217 .0 15 13 0.1
    log file sync 3,129 .0 14 5 0.1
    db file sequential read 9,753 .0 6 1 0.5
    control file sequential read 725 .0 0 0 0.0
    Data file init write 32 .0 0 7 0.0
    SQL*Net message to client 88,906 .0 0 0 4.2
    log file switch completion 2 .0 0 63 0.0
    SQL*Net break/reset to clien 1,120 .0 0 0 0.1
    rdbms ipc reply 4 .0 0 8 0.0
    direct path write 10 .0 0 3 0.0
    SQL*Net more data to client 1,120 .0 0 0 0.1
    db file single write 2 .0 0 6 0.0
    os thread startup 2 .0 0 6 0.0
    log file single write 2 .0 0 4 0.0
    log file sequential read 2 .0 0 3 0.0
    SQL*Net more data from clien 160 .0 0 0 0.0
    LGWR wait for redo copy 108 .0 0 0 0.0
    direct path read 10 .0 0 0 0.0
    SQL*Net message from client 88,906 .0 55,500 624 4.2
    virtual circuit status 120 100.0 3,588 29900 0.0
    Streams AQ: qmn slave idle w 127 .0 3,550 27949 0.0
    Streams AQ: qmn coordinator 260 51.2 3,550 13652 0.0
    class slave wait 2 100.0 10 4994 0.0
    SGA: MMAN sleep for componen 9 22.2 0 4 0.0
    Background Wait Events DB/Inst: ABCTEST/abctest Snaps: 2168-2169
    -> ordered by wait time desc, waits desc (idle events last)
    Avg
    %Time Total Wait wait Waits
    Event Waits -outs Time (s) (ms) /txn
    log file parallel write 11,978 .0 52 4 0.6
    db file parallel write 3,089 .0 16 5 0.1
    control file parallel write 1,211 .0 15 13 0.1
    db file scattered read 175 .0 0 1 0.0
    control file sequential read 33 .0 0 2 0.0
    db file sequential read 53 .0 0 1 0.0
    direct path write 10 .0 0 3 0.0
    os thread startup 2 .0 0 6 0.0
    log file single write 2 .0 0 4 0.0
    log file sequential read 2 .0 0 3 0.0
    events in waitclass Other 108 .0 0 0 0.0
    direct path read 10 .0 0 0 0.0
    rdbms ipc message 19,991 57.4 31,320 1567 0.9
    pmon timer 1,208 100.0 3,590 2972 0.1
    Streams AQ: qmn slave idle w 127 .0 3,550 27949 0.0
    Streams AQ: qmn coordinator 260 51.2 3,550 13652 0.0
    smon timer 12 100.0 3,302 275149 0.0
    SGA: MMAN sleep for componen 9 22.2 0 4 0.0
    Operating System Statistics DB/Inst: ABCTEST/abctest Snaps: 2168-2169
    Statistic Total
    AVG_BUSY_TIME 30,152
    AVG_IDLE_TIME 328,781
    AVG_SYS_TIME 4,312
    AVG_USER_TIME 25,757
    BUSY_TIME 120,981
    IDLE_TIME 1,315,433
    SYS_TIME 17,612
    USER_TIME 103,369
    RSRC_MGR_CPU_WAIT_TIME 0
    VM_IN_BYTES 353,361,920
    VM_OUT_BYTES 163,041,280
    PHYSICAL_MEMORY_BYTES 3,755,851,776
    NUM_CPUS 4
    NUM_CPU_CORES 1
    Request you to help me.
    Thanks in Advance,
    Rajesh

    Hi CKPT,
    Thanks for your reply.
    The main finding that I have got from addm report (in both the cases i.e when performance was good initially vis a vis when performance deteriorated is the same -
    FINDING 1: 100% impact (3234 seconds)
    Significant virtual memory paging was detected on the host operating system.
    RECOMMENDATION 1: Host Configuration, 100% benefit (3234 seconds)
    ACTION: Host operating system was experiencing significant paging but no
    particular root cause could be detected. Investigate processes that
    do not belong to this instance running on the host that are consuming
    significant amount of virtual memory. Also consider adding more
    physical memory to the host.
    I still am unable to find out the reasons ... pls help.
    Thanks
    Rajesh

  • [Solved] embedded videos in firefox take a lot of CPU time

    Playing embeded videos in Firefox take a lot of CPU time. Actually my old computer is not able to play these videos correctly if they are in HD. The problem appears with flash videos (not so surprising, flash sucks...) but also with html5 videos (there is an option in youtube to turn that on). However if I succeed to have the direct URL, these videos play perfecrtlky fine in mplayer using not more than 10-20% of CPU time. Is there a solution to that? Is there any possibility to use an external player to play HTML5 videos in firefox? If anybody knows, Why this problem, are the mozilla folk aware of this problem? (Note that I posted a thread a long time ago for this problem but concerning flash only)
    Last edited by olive (2012-04-27 20:33:59)

    There's not much you can do to make HTML5 videos as fast as Xv, see http://swfdec.freedesktop.org/wiki/FAQ. They are slow for the same basic reason as Flash... the video overlay cannot be used because the standard allows for controls and CSS to be rendered on top of the video.
    As for redirecting to an external player... this is not as easy as it could be. If the videos appeared in <embed> tags or <object> tags, one could use Mozplugger, Media Player Connectivity and other programs, but I don't think one has been written to handle the <video> tag. An upcoming update to firefox will make it use gstreamer, however. If this still results in slow playback, it will at least make it easier to use an external player. I imagine you would have to patch firefox to make it use a port on the localhost as the video sink instead of the screen. Then you would run gst-launch to receive that RTP stream.

  • Too much exclusive CPU time counted at swapcontext function

    Hi,
    I'm using Sun Studio Express March 2009 Build, especially Performance Analyzer, and I have observed some hardly understandable CPU times measured at swapcontext function of libc library.
    Here is my machine spec.
    Two-way Intel E5320 processors with 16GB memory
    SUSE Linux Enterprise Server 10 SP1 (x86_64)
    My program consisted of 8 threads (pthread), and around a hundred of user contexts (coroutines or fibers) run on every single thread. I'm using makecontext/swapcontext for creating/scheduling user contexts on threads.
    I'm using both Sun Studio Performance Analyzer and Intel VTune Performance Analyzer.
    My problem is that performance analyzer reported about 20% of total CPU time as the exclusive CPU time of swapcontext function, while I couldn't find as many HW event samples related to swapcontext by using VTune.
    To narrow down the problem scope, I made simple test program, and I reproduced the problem. I attached the test program generator written by bash script at the end of this message.
    I generated the test program with following command.
    % bash code_gen.sh 8 128 100000 1000
    Then, you can get the test program, which consists of 8 threads with 128 user contexts at each threads, and 100000 times of context switch at each user context.
    In my system, Sun Studio Performance Analyzer reported 328 seconds of exclusive CPU time at swapcontext out of 463 seconds total CPU time (CPU Time of <Total>). Briefly, swapcontext consumed about 70% of total CPU time.
    However, according to VTune sampling, both libc-2.4.so and vmlinux-2.6.16.46-0.12-smp consume only 8% of total clockticks.
    It's too large gap between Sun Studio and VTune.
    Have you seen this kind of problem? Do you know why this mismatch happens?
    Or how can I estimate actual swapcontext cost?
    Thank you for reading my post, and I'm looking forward to some hints about my problem.
    Colin
    ---- code_gen.sh ----
    #!/bin/bash
    usage()
         echo "code_gen.sh <num_threads> <num_task> <num_loop> <func_body_size>"
    test()
         local num_threads=$1
         local num_tasks=$2
         local func_loop=$3
         local func_body_size=$4
         local file_name="mytest_${num_threads}_${num_tasks}_${func_loop}_${func_body_size}"
         main_func_gen $num_tasks $func_loop $func_body_size > $file_name.c
         gcc -O2 $file_name.c -o $file_name -lpthread
    sub_func_gen()
         local func_id=$1
         local func_loop=$2
         local func_body_size=$3
         local num_tasks=$4
         cat <<!
    static void f$1(int threadId)
         volatile int c = 0;
         int i = 0;
         for(i = 0; i < $func_loop; ++i)
         for i in `seq 1 $func_body_size`; do
              echo "          c+=1;";
         done
         cat <<!
              swapcontext(&ctx[threadId][$func_id], &ctx[threadId][($func_id+1)%$num_tasks]);
    main_func_gen()
         num_tasks=$1
         func_loop=$2
         func_body_size=$3
         cat <<!
    #include <stdio.h>
    #include <ucontext.h>
    #include <stdlib.h>
    #include <sys/time.h>
    #include <time.h>
    #include <pthread.h>
    static ucontext_t **ctx;
    static ucontext_t *mctx;
    static pthread_t *pThreads;
         for i in `seq 0 $((num_tasks-1))`; do
              sub_func_gen $i $func_loop $func_body_size $num_tasks
         done
         cat <<!
    int
    threadMain (int* pThreadId)
    char** st = NULL;
    int i = 0;
    int* ret = NULL;
         int threadId=*pThreadId;
    printf("$num_tasks tasks on %d thread\n", threadId);
    st = (char**)malloc(sizeof(char*)*$num_tasks);
    ctx[threadId] =(ucontext_t*)malloc(sizeof(ucontext_t)*$num_tasks);
    ret = (int*)malloc(sizeof(int)*$num_tasks);
         for i in `seq 0 $((num_tasks-1))`; do
              cat <<!
    st[$i] = (char*)malloc(sizeof(char)*8192);
    getcontext(&ctx[threadId][$i]);
    ctx[threadId][$i].uc_stack.ss_sp = st[$i];
    ctx[threadId][$i].uc_stack.ss_size = 8192;
    ctx[threadId][$i].uc_link = &mctx[threadId];
    makecontext(&ctx[threadId][$i], f$i, 1, threadId);
         done
         cat <<!
    //printf("start\n");
    swapcontext(&mctx[threadId], &ctx[threadId][0]);
    return 0;
    int
    main(int argc, char* argv[])
         int num_threads = $num_threads;
         int rc;
         pthread_attr_t attr;
         void *status;
    struct timeval begin, end;
         int *threadId;
         int i;
         printf("%d threads\n", num_threads);
         pthread_attr_init(&attr);
         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
         pThreads = (pthread_t*)malloc(sizeof(pthread_t)*num_threads);
         mctx = (ucontext_t*)malloc(sizeof(ucontext_t)*num_threads);
         ctx = (ucontext_t**)malloc(sizeof(ucontext_t*)*num_threads);
         threadId = (int*)malloc(sizeof(int)*num_threads);
         // begin time measurement
    gettimeofday(&begin, NULL);
         for(i=0; i < num_threads; ++i)
              threadId[i] = i;
              rc = pthread_create(&pThreads, &attr, threadMain, (void*)&threadId[i]);
              if(rc)
                   printf("ERROR; return code from pthread_create is %d\n", rc);
                   exit(-1);
         pthread_attr_destroy(&attr);
         for(i = 0; i < num_threads; ++i)
              rc = pthread_join(pThreads[i], &status);
              if(rc)
                   printf("ERROR; return code from pthread_join is %d\n", rc);
                   exit(-1);
         // end time measurement
    gettimeofday(&end, NULL);
    printf("finished. Elapsed time=%dms\n", ((end.tv_sec - begin.tv_sec)*1000000+(end.tv_usec - begin.tv_usec))/1000);
         pthread_exit(NULL);
    if [[ $# -ne 4 ]]; then
         usage
         exit 0
    fi
    test $1 $2 $3 $4

    Hi Nik,
    Oh! I didn't know that. Here I put my code again. I'm sorry for your confusion.
    #!/bin/bash
    usage()
         echo "code_gen.sh <num_threads> <num_task> <num_loop> <func_body_size>"
    test()
         local num_threads=$1
         local num_tasks=$2
         local func_loop=$3
         local func_body_size=$4
         local file_name="mytest_${num_threads}_${num_tasks}_${func_loop}_${func_body_size}"
         main_func_gen $num_tasks $func_loop $func_body_size > $file_name.c
         gcc -O2 $file_name.c -o $file_name -lpthread
    sub_func_gen()
         local func_id=$1
         local func_loop=$2
         local func_body_size=$3
         local num_tasks=$4
         cat <<!
    static void f$1(int threadId)
         volatile int c = 0;
         int i = 0;
         for(i = 0; i < $func_loop; ++i)
         for i in `seq 1 $func_body_size`; do
              echo "          c+=1;";
         done
         cat <<!
              swapcontext(&ctx[threadId][$func_id], &ctx[threadId][($func_id+1)%$num_tasks]);
    main_func_gen()
         num_tasks=$1
         func_loop=$2
         func_body_size=$3
         cat <<!
    #include <stdio.h>
    #include <ucontext.h>
    #include <stdlib.h>
    #include <sys/time.h>
    #include <time.h>
    #include <pthread.h>
    static ucontext_t **ctx;
    static ucontext_t *mctx;
    static pthread_t *pThreads;
         for i in `seq 0 $((num_tasks-1))`; do
              sub_func_gen $i $func_loop $func_body_size $num_tasks
         done
         cat <<!
    int
    threadMain (int* pThreadId)
        char** st = NULL;
        int i = 0;
        int* ret = NULL;
         int threadId=*pThreadId;
        printf("$num_tasks tasks on %d thread\n", threadId);
        st = (char**)malloc(sizeof(char*)*$num_tasks);
        ctx[threadId] =(ucontext_t*)malloc(sizeof(ucontext_t)*$num_tasks);
        ret = (int*)malloc(sizeof(int)*$num_tasks);
         for i in `seq 0 $((num_tasks-1))`; do
              cat <<!
            st[$i] = (char*)malloc(sizeof(char)*8192);
            getcontext(&ctx[threadId][$i]);
            ctx[threadId][$i].uc_stack.ss_sp = st[$i];
            ctx[threadId][$i].uc_stack.ss_size = 8192;
            ctx[threadId][$i].uc_link = &mctx[threadId];
            makecontext(&ctx[threadId][$i], f$i, 1, threadId);
         done
         cat <<!
        //printf("start\n");
        swapcontext(&mctx[threadId], &ctx[threadId][0]);
        return 0;
    int
    main(int argc, char* argv[])
         int num_threads = $num_threads;
         int rc;
         pthread_attr_t attr;
         void *status;
        struct timeval begin, end;
         int *threadId;
         int i;
         printf("%d threads\n", num_threads);
         pthread_attr_init(&attr);
         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
         pThreads = (pthread_t*)malloc(sizeof(pthread_t)*num_threads);
         mctx = (ucontext_t*)malloc(sizeof(ucontext_t)*num_threads);
         ctx = (ucontext_t**)malloc(sizeof(ucontext_t*)*num_threads);
         threadId = (int*)malloc(sizeof(int)*num_threads);
         // begin time measurement
        gettimeofday(&begin, NULL);
         for(i=0; i < num_threads; ++i)
              threadId[i] = i;
              rc = pthread_create(&pThreads, &attr, threadMain, (void*)&threadId[i]);
              if(rc)
                   printf("ERROR; return code from pthread_create is %d\n", rc);
                   exit(-1);
         pthread_attr_destroy(&attr);
         for(i = 0; i < num_threads; ++i)
              rc = pthread_join(pThreads[i], &status);
              if(rc)
                   printf("ERROR; return code from pthread_join is %d\n", rc);
                   exit(-1);
         // end time measurement
    gettimeofday(&end, NULL);
    printf("finished. Elapsed time=%dms\n", ((end.tv_sec - begin.tv_sec)*1000000+(end.tv_usec - begin.tv_usec))/1000);
         pthread_exit(NULL);
    if [[ $# -ne 4 ]]; then
         usage
         exit 0
    fi
    test $1 $2 $3 $4best regards,
    Colin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Publishing topology causes high CPU times? What?

    I have a mixed environment currently with 2 lync 2010 front ends (Production) and 4 lync 2013 front ends (pilot pools).
    When I make a change and publish the topology all 6 2010 and 2013 front ends go to 100% CPU time.  IIS Worker Process is to blame and issuing "iisreset" on each server fixes it.
    Where do I ever begin to diagnose this? No odd network traffic in packet captures, but I know right away when it happens as SCOM starts blowing up on CPU time and Lync conference join errors.

    Each 60 seconds a task is run to determine if a change has been made to the CMS master and needs to be replicated. If a change was made, all replica need to synchronize with the CMS master. The replication may cause the high CPU usage. You should check the
    duration of the High CPU usage. I think once the replication completes, the CPU usage will go down.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • V$osstat and V$SYS_TIME_MODEL - how to get CPU time from instance

    Hi there !
    I have a function osstat, which take stats from the os using v$osstat (credits for the procedure to a person, I regret to say, that I cant remember his name). But since we have 9 databases on the same server (and we dont have access to the server os itself (outsourcing stinks), we often would like to know more about cpu, waits etc. And one of the procedures we use is the osstat.
    I have tried to combine it with V$SYS_TIME_MODEL in oder to se how much of the OS CPU time comes from the instance I am on at the moment, but I'm not able to figure out how to do it exaclty.
    This is my code:
    DROP TYPE OSSTAT_RECORD;
    CREATE OR REPLACE TYPE osstat_record IS OBJECT (
      date_time_from TIMESTAMP,
      date_time_to TIMESTAMP,
      idle_time NUMBER,
      user_time NUMBER,
      sys_time NUMBER,
      iowait_time NUMBER,
      nice_time NUMBER,
      instance_cpu_time NUMBER
    DROP TYPE OSSTAT_TABLE;
    CREATE OR REPLACE TYPE osstat_table AS TABLE OF osstat_record;
    CREATE OR REPLACE FUNCTION osstat(p_interval IN NUMBER default 5, p_count IN NUMBER default 2, p_dec in number default 0)
       RETURN osstat_table
       PIPELINED
    IS
      l_t1 osstat_record;
      l_t2 osstat_record;
      l_out osstat_record;
      l_num_cpus NUMBER;
      l_total NUMBER;
      l_instance NUMBER;
    BEGIN
      l_t1 := osstat_record(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
      l_t2 := osstat_record(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
      SELECT value
      INTO l_num_cpus
      FROM v$osstat
      WHERE stat_name = 'NUM_CPUS';
      FOR i IN 1..p_count+1
      LOOP
        SELECT systimestamp, sum(decode(stat_name,'IDLE_TIME', value, NULL)) as idle_time,
               sum(decode(stat_name,'USER_TIME', value, NULL)) as user_time,
               sum(decode(stat_name,'SYS_TIME', value, NULL)) as sys_time,
               sum(decode(stat_name,'IOWAIT_TIME', value, NULL)) as iowait_time,
               sum(decode(stat_name,'NICE_TIME', value, NULL)) as nice_time
        INTO l_t2.date_time_to, l_t2.idle_time, l_t2.user_time, l_t2.sys_time, l_t2.iowait_time, l_t2.nice_time
        FROM v$osstat
        WHERE stat_name in ('IDLE_TIME','USER_TIME','SYS_TIME','IOWAIT_TIME','NICE_TIME');
        select value/100000
        into l_t2.instance_cpu_time
        from  V$SYS_TIME_MODEL
        where stat_name = 'DB time';
        l_out := osstat_record(l_t1.date_time_from, systimestamp,
                               (l_t2.idle_time-l_t1.idle_time)/l_num_cpus/p_interval,
                               (l_t2.user_time-l_t1.user_time)/l_num_cpus/p_interval,
                               (l_t2.sys_time-l_t1.sys_time)/l_num_cpus/p_interval,
                               (l_t2.iowait_time-l_t1.iowait_time)/l_num_cpus/p_interval,
                               (l_t2.nice_time-l_t1.nice_time)/l_num_cpus/p_interval,
                               ((l_t2.instance_cpu_time-l_t1.instance_cpu_time)/100));  --- >>  Should I divide by no of cpus here as well???  Or ???
        l_total := l_out.idle_time+l_out.user_time+l_out.sys_time+l_out.iowait_time+nvl(l_out.nice_time,0);
        if l_out.user_time > 0 then
           l_instance := (l_out.instance_cpu_time*100)/l_total;   ->> instance in percent of the total cputime
        else
           l_instance := 0;
        end if;
        if i > 1 then
        PIPE ROW(osstat_record(l_t1.date_time_to, systimestamp,
                               trunc((l_out.idle_time/l_total*100),p_dec),
                               trunc((l_out.user_time/l_total*100),p_dec),
                               trunc((l_out.sys_time/l_total*100),p_dec),
                               trunc((l_out.iowait_time/l_total*100),p_dec),
                               trunc((l_out.nice_time/l_total*100),p_dec),
                               trunc(l_instance,p_dec)));
        end if;
        l_t1 := l_t2;
        sys.dbms_lock.sleep(p_interval);
      END LOOP;
      RETURN;
    END;
    /I get ie a USER CPU Time of 15% fo a given interval of 5 mins - and a cputime for the instance of 50 - and others are 5% and 1%.
    My brain has stopped working now .... I'm stuck
    Mette

    mettemusens wrote:
    Hi there !Duplicate thread:
    Re: v$osstat and V$SYS_TIME_MODEL question
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to find top 10  SQL statments which are consuming more cpu time.

    hi all,
    Is there any command or script to monitor the top 10 sql statments which are consuming more cpu time.
    I know by using AWR REPORT we can find it, i want the command or script to find the top cpu utilization sql statments.
    Regards
    Subhash.

    Subhash,
    A quick and dirty Google search could have get you started with the following:
    Thread: how to get top CPU consuming sql oracle 10g
    Re: how to get top CPU consuming sql oracle 10g
    Oracle SQL top sessions
    http://www.dba-oracle.com/oracle10g_tuning/t_sql_top_sessions.htm
    "How to Find top 10 expensive sql's", version 9.2.0
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:73325450402303
    HTH,
    Thierry

  • Incompatible in unix? calculating cpu time in swing ?

    I am confused about the fact that when I run my swing program in netbeans on windows xp platform. The buttons have the ability to traverse the focus around using TAB key. But when I run the program in unix, the TAB key has no effect on the focus at all. I really want the TAB key to work !!!
    Also, anyone knows if java has a method to calculate cpu time? I can only use System.currentTimeMillis() to measure the wall clock time. But I will need the actual cpu time spent on that particular thread.
    Can somebody help ? Thanks !!!

    the TAB key has no effect on the focus at all. I
    really want the TAB key to work !!!This is an OS specific thing, not a Java thing
    Also, anyone knows if java has a method to calculate
    cpu time? I can only use System.currentTimeMillis()
    to measure the wall clock time. But I will need theNo. No such method exists. However you can use diagnostic packages like JProbe

  • Focus buttons and cpu time

    I am confused about the fact that when I run my swing program in netbeans on windows xp platform. The buttons have the ability to traverse the focus around using TAB key. But when I run the program in unix, the TAB key has no effect on the focus at all. I really want the TAB key to work !!!
    Also, anyone knows if java has a method to calculate cpu time? I can only use System.currentTimeMillis() to measure the wall clock time. But I will need the actual cpu time spent on that particular thread.
    Can somebody help ? Thanks !!!

    The problem is, there is no such process. In Windows Task Manager all the processes use 0%, and System Idle is 99%, but CPU usage on the Performance tab is still high.

  • Uncorrelated GC STW pauses in ParNew + sys cpu time spikes from jvm calls

    Hi, JVM experts.
    GC is not an easy subject to grab all its subtleties, so I'm looking for some advice with my situation where to dig further.
    The overall picture:
    1) Linux smp (2.6.5) x86_64 host with 8G memory, 2x2Ghz xeon (HT) CPUs
    Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b05, mixed mode)
    2) Heap: -Xms4500M -Xmx4500M -XX:MaxNewSize=128m -XX:NewSize=128m -XX:MaxPermSize=128m -XX:PermSize=128m
    3) GC: -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=0 -XX:SurvivorRatio=128 -XX:CMSInitiatingOccupancyFraction=60 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintClassHistogram
    4) Application is running under consistent traffic for two weeks.
    5) I monitor the system with "sar"
    6) Once or twice a week I observe the kernel-space cpu usage spike to ~90% for a duration <10 seconds.
    7) I detect the cpu spike and dump a snapshot of the system situation. It's the JVM which consumes the syscpu time. JVM is sent SIGQUIT at the same instant.
    There are two points, I'm rather vague about.
    1) All cpu load situations have the following similar pattern in GC log file:
    195098.019: [GC 195098.019: [ParNew
    Desired survivor size 491520 bytes, new threshold 0 (max 0)
    : 129152K->0K(130112K), 0.0754030 secs] 1549718K->1448253K(4607040K), 0.0755550 secs]
    Total time for which application threads were stopped: 0.0758180 seconds
    Application time: 0.5316910 seconds
    Total time for which application threads were stopped: 0.0003550 seconds
    Application time: 0.0695990 seconds
    Total time for which application threads were stopped: 0.0001620 seconds
    Application time: 0.1657730 seconds
    Total time for which application threads were stopped: 0.0001780 seconds
    Application time: 0.0000350 seconds
    Total time for which application threads were stopped: 0.0000440 seconds
    Application time: 0.2738210 seconds
    Total time for which application threads were stopped: 0.0003530 seconds
    Application time: 0.3108570 seconds
    195099.448: [GC 195099.448: [ParNew
    Desired survivor size 491520 bytes, new threshold 0 (max 0)
    : 129151K->0K(130112K), 0.0712390 secs] 1577405K->1476947K(4607040K), 0.0713980 secs]
    Total time for which application threads were stopped: 0.0716750 seconds
    Application time: 0.0364560 seconds
    Total time for which application threads were stopped: 8.2666520 seconds
    Application time: 0.0000700 seconds
    Total time for which application threads were stopped: 0.0055730 seconds
    Application time: 0.0069140 seconds
    Total time for which application threads were stopped: 0.0017350 seconds
    Application time: 0.0011930 seconds
    Total time for which application threads were stopped: 0.0064760 seconds
    Application time: 0.0000720 seconds
    Total time for which application threads were stopped: 0.0001120 seconds
    Application time: 0.0001010 seconds
    Total time for which application threads were stopped: 0.0000650 seconds
    Application time: 0.0001570 seconds
    195107.840: [Full GC 195107.840: [CMS: 1476947K->1092516K(4476928K), 7.6193100 secs] 1488921K->1092516K(4607040K), [CMS Perm : 46862K->46641K(131072K)], 7.6194800 secs]
    num #instances #bytes class name
    1: 1962568 306032400 [Ljava.util.HashMap$Entry;
    2: 1962446 125596544 java.util.HashMap
    The "delay" of the SIGQUIT/Histogram dump can be ~1-2 seconds from the CPU overload detection. I'm curious about the "suspeciously spurious" SWT preceding the cpu spike. What could be the possible reasons?
    2) Per thread analysis of the JVM threads hinted me to one thread which sometimes monopolized ~60% of the cpu time in kernel space. This is the native posix thread which "calls back into" JVM on certain events. Could it somehow cause the aforementioned STW?
    My attempts to get a gdb stack dump at cpu load event failed (gdb can't resolve the stack in some of the jvm threads and enters infinite loop)
    Any advice is greatly appreciated
    regards,
    - andrey

    Just to close my "ticket" with some findings on the way hopefully to be useful for somebody else.
    Since the problem manifested itself only on Linux box (have tried two different enterprise production kernels 2.6), I couldn't use dtrace, so my choice was limited to systap and /proc/profile.
    The pattern when cpu usage was spiking was the following:
    15 get_stack 0.1042
    31 unhandled_signal 0.6458
    34 stub_rt_sigreturn 0.2297
    49 copy_siginfo_to_user 0.1021
    70 find_vma 0.6250
    94 retint_signal 0.7705
    100 do_sigaltstack 0.2604
    138 is_prefetch 0.3920
    211 __up_read 1.1989
    252 system_call 1.9535
    292 __down_read 1.9730
    552 save_i387 2.8750
    1501 do_page_fault 0.9381
    2266 do_signal 1.3488
    2427 get_signal_to_deliver 1.9700
    2452 force_sig_info 11.7885
    3715 sys_rt_sigreturn 5.1597
    14260 total 0.0057
    It has been always the extensive number of signals generated. systap is lacking dtace java probes (as well as any u-level probes for that matter), so I could tap only in the kernel on syscalls:
    force_sig_info= 10209 &#8211; 10230
    0xc043681b : force_sig_info+0x1/0x86
    0xc04230d3 : force_sig_info_fault+0x24/0x28
    0xc0404670 : sys_rt_sigreturn+0x0/0xff
    0xc061e3d8 : kprobe_exceptions_notify+0x164/0x386
    0xc061f043 : notifier_call_chain+0x2a/0x47
    0xc061f07e : atomic_notifier_call_chain+0x17/0x1a
    0xc061f011 : do_page_fault+0x5e7/0x5ef
    0xc0400000 : startup_32+0x0/0xb4
    sys_rt_sigreturn= 10209 &#8211; 10235
    0xc0404671 : sys_rt_sigreturn+0x1/0xff
    0xc040518a : syscall_call+0x7/0xb
    0xc0400000 : startup_32+0x0/0xb4
    sys_rt_sigreturn() is tricky (it is designed to return to the kernel from the u-space signal handler), but the force_sig_info() is the result of the do_page_fault(). The swap was disabled and I assumed that page faults were "minor"-s. Looking at the comments in the OpenJDK JVM sources I could see that there are cases for non-mapped regions singal handling (like dynamic stack growth), so I suspected it's something very JVM specific. I could not correlate it precisely to GC events.
    The end of the story is that I didn't find out exactly what was the real trigger of this event, but JVM1.6.05 does not produce such CPU spilkes.
    - a.

  • Standalone program utlising 100 percent CPU time

    We are struck with a problem, our standalone program is occupying most of cpu time and limiting existing processes access to cpu. We need to bring down cpu utilization of the process.
    Java program when run polls to MQ, gets the xml message from mq, stores in databse, spans a thread which converts the message to relevant sql statements, executes them on the database. There is a limitation on maximum threads can be allowed, if more messages than max count of threads arrive they are stored and when the threads are free this message would be passed to a newly created thread.
    Thread pooling is not implemented.

    Hi
    I think I found the cause to my problem and also solved it?
    When I investigated my "Console Log" the next message was repeated :
    ... mDNSResponder[202] Failed to obtain NAT port mapping from router 10.0.1.1 external address xxx.xxx.xxx.xxx internal port 9999
    This gave me an idea and pointed in the NAT configurations.
    What have I done (which solved my problem) :
    • opened "Airport Utility"
    • selected my Airport Base Station
    • choose "manual Setup"
    • choose "internet connection"
    • after that i selected the tab "NAT"
    • where I deactivated "Enable NAT port mapping protocol"
    • and then I updated my Airport Base station
    => since then, no more the problem and de message disappeared from the "Console Log"
    Greetings
    Peter

Maybe you are looking for

  • Icloud storage help

    I believe my I cloud storage is corrupted can you check it? whatever I backup comes back with unresponding apps or there may be a problem with my ipad's data that I do not understand now I have reset my ipad without using icloud now the apps work but

  • Event Alert in Oracle Application

    Hi all, Reqquirement- I am having one task custom form in that form we assign a task to our employee.when i assign a task on that form, mail alert should fire & mail should send to that employee. Query- When i save a record on my form alert get fired

  • How to force duplicate row display automatically

    In answers, we have one table that has duplicate data. The only thing different between some rows is the ROWID. When use user requests data, Answers automatically suppresses the duplicate rows. How can I force answers to display all rows and not supp

  • CS5 not working-Java problem?

    Hi, Just installed 10.9 and found myself unable to use my Adobe CS5. My computer is asking for Java SE 6 Runtime and tries to automatically load the software-but fails. Alert says the software can't be found on the server-??? Installed Java 7 from th

  • Accounting entries in invoice

    Hi, I have cancel the invoice document with amount usd 600, system create the accounting entries as below.. Vendor: USD 600 Debit GR/IR Clearing account: USD 154600 Credit  Purchase Service account: USD 154000 Debit Is these entries are correct if no