How to interpret py-spy profiling results from tornado web server?

Viewed 172

I'm trying to profile a tornado web server running in a docker container using py-spy.

I used the instructions at https://github.com/benfred/py-spy to set up the profiling workflow and it seems to work and give results, but I have a hard time understanding what is going on as two processes seem to have an overwhelmingly large contribution, but are not related to the rest of the service in the flamegraph.

Putting a load on the server and looking at the top command like this docker-compose -f docker-compose.profile.yml run pyspy top --pid 10621 --subprocesses --full-filenames gives the following top contributions:

  %Own   %Total  OwnTime  TotalTime  Function (filename)                                                                                                                                                                                                                         
1600.00% 1600.00%   249.4s    249.4s   _run (/usr/local/lib/python3.8/site-packages/pymongo/periodic_executor.py)
1553.00% 1600.00%   244.9s    249.4s   _worker (/usr/local/lib/python3.8/concurrent/futures/thread.py)
 23.00%  23.00%    2.57s     2.57s   read (/usr/local/lib/python3.8/ssl.py)
...

The flamegraph looks like this:

flamegraph

As you can see the contribution from other processes is close to negligible. My question is how to interpret these results. Is it the real usage or an artifact of asynchronous (which a lot of the code is) programming that the parts of the code which manage the async calls are shown?

0 Answers
Related