Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I find out if a process is bound to CPU, Memory or Disk?

share|improve this question
    
If you're using a gnome GUI, you can add the System Monitor applet to your panel. In the settings you can set cycles lost to IO-Wait to show up as white, and set the Memory, CPU and Disk Read / Write graphs to show. I usually change the default graph colours to make it easier to distinguish user/OS memory and disk read/write. It's not a real solution, but it's handy to have alongside all the tools mentioned in the answers. –  Jeremy Nov 17 '10 at 1:47
    
@luis-alvarado I would disagree that this question isn't useful, though I'd argue this might fit in better on StackOverflow or the like. I came here looking for a solution. –  distilledchaos May 12 at 18:42
add comment

5 Answers 5

That requires some voodoo. It depends. Example:

  • If there's enough of memory and disks don't seem too busy, it may be CPU-bound. Look at CPU usage and if its bordering at 100% it's CPU bound. If it's not there's an artificial bottleneck in the implementation. E.g. on a multi-core CPU a single threaded process will not go above 50% CPU usage.

  • If CPU and memory are available, but disks are very busy, or IO latency seems high, its likely that its IO bound. See if adding more disks (RAID?) helps.

  • None of the above? Check memory available.

  • Enough memory? There may be an artificial bottleneck in the process itself i.e. maybe someone forgot to remove a sleep(1)? Naah its not that easy usually. ;)

There's a reason why we have a whole lab for performance engineers in most companies dealing with performance sensitive products!

Use tools like sar, vmstat, iostat, oprofile, lockstat, dtrace, product specific perf monitoring tools etc, to debug perf problems.

share|improve this answer
    
Is there a tool that ties all these together? –  ssanj Aug 7 '10 at 6:15
    
usually no, but if dtrace is available on your system (Solaris/FreeBSD/Mac OS X?) you may get far just by using that. –  Sudhanshu Aug 7 '10 at 6:21
    
I just remembered there's Systemtap on linux (similar to dtrace), except I am not sure about the maturity of the tool. –  Sudhanshu Aug 7 '10 at 6:34
add comment

A tool that can be useful for real-time checking a number of process statistics (memory, cpu-usage, I/O, etc.) is htop. It doesn't replace the more specialised tools named by Sudhanshu, but might be a good start.

share|improve this answer
    
+1 Htop is a great tool. –  Decio Lira Aug 8 '10 at 0:58
add comment

check out iotop, can be useful

share|improve this answer
add comment

Run top and look at the cpu usage line. A high user % indicates that it is cpu bound. A high wait % indicates that it is IO bound.

share|improve this answer
add comment

As well as the other tools mentioned, run ps l PID, inserting the relevant process id, or look at the STATE and WCHAN columns in top or htop.

If it's in D (for disk) state, then it's doing file IO. This could be because it's either reading a lot of files, or because it's using a lot of memory and swapping. The WCHAN column will tell you what kernel function it's inside; googling for them or asking here may give you some indication what they mean.

If it's in R (run) state, it's using the CPU in user space, in other words it's CPU bound at that moment.

If it's in S (sleep) state, it's inside an interruptible system call, which may mean it's either actually sleeping, or it's doing something like waiting for network traffic or a lock. Again, looking at the specific wchan will tell you more.

See also What is the "Waiting Channel" of a process?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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