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

2019-02-01 11:55发布

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.

2条回答
孤傲高冷的网名
2楼-- · 2019-02-01 12:16

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:

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.

查看更多
迷人小祖宗
3楼-- · 2019-02-01 12:39

Unless you have a latency built into the system, just run the application for some time on a dedicated machine and check the CPU counters. If the app uses 100% of the CPU core it can access, it's CPU bound. Otherwise, it spends time on other things like memory allocations and IOs.

查看更多
登录 后发表回答