Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

pyflame shows cpu is high idle, but nmon command shows cpu is full load. #102

Closed
coder-zhuyu opened this issue Aug 1, 2017 · 4 comments
Closed

Comments

@coder-zhuyu
Copy link

I run tornado with aiomysql on ubuntu 16.04, python version is 3.5.2.
I only execute a simple select db query on mysql.
pyflame shows cpu is high idle, but nmon command shows cpu is full load.
It's so strange?

@eklitzke
Copy link
Collaborator

eklitzke commented Aug 1, 2017

Can you tell me what version of Pyflame you're using, and also what flags you're passing to Pyflame?

If the app is threaded, make sure you are using --threads with Pyflame.

You also might want to try running with -s 0 to see if you get a reasonable looking stack trace.

@coder-zhuyu
Copy link
Author

pyflame 1.4.4, Compiled Jul 26 2017, 10:43:24 by GCC 5.4.0 20160609
The app is not threaded.
sudo pyflame -s 5 -r 0.001 -o prof.txt 6505
The flame picture is shown: https://coder-zhuyu.github.io/images/prof-tornado.svg

@eklitzke
Copy link
Collaborator

eklitzke commented Aug 1, 2017

This looks pretty normal to me. You can use -x to exclude the idle times, but you probably already know that.

My guess is that if you use GDB to attach to the process, you will see that it's frequently blocking in the Tornado event loop. IIRC, you'll see a call to something like __epoll_wait() as frame 0 as reported by the GDB bt command. Try getting a backtrace from GDB a dozen times or so, and if Pyflame says your program is idle about 50% of the time then you should see the __epoll_wait() call about 50% of the time as well.

@coder-zhuyu
Copy link
Author

I understand.
Thank you for your answer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants