5

I've got a problem with my system where phantomjs remains running after finishing its job. To debug this issue, two days ago I rebooted the system:

Screen shot showing two days of uptime

Today when I ran top, I saw this:

screen shot of "top" showing phantomjs processes with 130+ in the "time" column

If I understand right these two phantomjs process have been there for about 5 days. So they somehow survived the reboot?

10

The TIME+ column is not wallclock time in hours and minutes, but CPU time consumed in minutes and seconds (and hundredths of a second). Your screen shot shows two phantomjs processes which have used a bit over two hours' CPU time each.

  • So this does not necessarily mean they started around two hours ago? – shenkwen Jul 22 '16 at 16:54
  • 3
    No. It means they used any cpu core(s) for a little over two hours since they were started. Although this would be rather strange a process MIGHT use more CPU time than the system had uptime. But that would really stress the CPU ... – Phillip -Zyan K Lee- Stockmann Jul 22 '16 at 18:50
  • 6
    @Phillip-ZyanKLee-Stockmann: on a many-core system, it's easy for a multi-threaded process to use more than 100% of CPU time. e.g. x264 (the video encoder) on a quad-core system typically gets 360% to 380% of the available 400%, depending on other load. On a server that runs a long-lived CPU-intensive multi-threaded program at bootup, it would be normal to see this. – Peter Cordes Jul 23 '16 at 2:47
11

From man top, section "3a. Description of fields":

   29. TIME  --  CPU Time
       Total  CPU  time the task has used since it started.  When Cumulative 
       mode is On, each process is listed with the cpu time that it and its 
       dead children have used.  You toggle Cumulative mode with `S',  which  
       is  both  a  command-line option and an interactive command. 
       See the `S' interactive command for additional information regarding 
       this mode.

   30. TIME+  --  CPU Time, hundredths
       The same as TIME, but reflecting more granularity through hundredths 
       of a second.

CPU time means how long a single CPU core was busy processing this task or (if Cumulative mode is on) any of its children here.

That means the CPU time is not related to wall time at all, it can of course be shorter than how long the process is running in wall time (if it does not use a full CPU core all the time), but it can also be longer than the real process runtime (if you have a multi-core CPU and the process uses more than one of them).

  • For multithreaded programs I think it will show the sum across all threads. That means even without using cumulative mode, it is possible to see CPU time higher than the uptime. – kasperd Jul 22 '16 at 17:58
  • 1
    @kasperd Sure, but this is only possible on multi-core machines. On single core machines, while one thread is running the others are not. – Random832 Jul 22 '16 at 23:14
  • @Random832 The same is true of the cumulative CPU time. The total measured cannot be larger than the uptime multiplied by the number of CPU threads. – kasperd Jul 23 '16 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.