Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if app is cpu-bound or memory-bound?

I've got an application that does few computational CPU work, but mostly memory accesses (allocating objects and moving them around, there's few numeric or arithmetic code).

How can I measure the share of the time that am I spending in memory access latencies (due to cache misses), with the CPU being idle?

I should note that the app is running on a Hyper-V guest; I'm not sure it will pose any difficulties, but it might.

like image 596
jkff Avatar asked Jul 01 '10 09:07

jkff


People also ask

How do I know if my code is 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 dual-core CPU a single threaded process will not go above 50% CPU usage.

How do you tell if a process is CPU or IO bound?

CPU Bound. It is easy to see if a system is CPU bound or not. Simply type `htop` at the command line and press enter.

What is IO bound app?

Any application that involves reading and writing data from an input-output system, as well as waiting for information, is considered I/O bound. These include applications like word processing systems, web applications, copying files, and downloading files.

How do I O bound and CPU-bound programs differ?

CPU Bound means the rate at which process progresses is limited by the speed of the CPU. A task that performs calculations on a small set of numbers, for example multiplying small matrices, is likely to be CPU bound. I/O Bound means the rate at which a process progresses are limited by the speed of the I/O subsystem.


1 Answers

You could always profile your application to see where it spends most of the time.

You can learn a lot about your application's behaviour and data access patterns this way.

If you are using Linux, you have a wide range of available tools for profiling, like:

  • OProfile
  • sysprof
  • valgrind + kcachegrind

EDIT:

For a more exact measurement of the processor performance as well as memory accesses, you could also try the AMD CodeAnalyst Performance Analyzer. Here are instructions on how to use it with Intel processors, though I haven't tried it myself.

Another tool that you might also find useful is the Intel Performance Tuning Utility.

like image 170
the_void Avatar answered Oct 11 '22 14:10

the_void