This patch enables profiling (capturing function call trace like
cProfile ) worker processes on the fly while service is running.
User requests the oslo service process to start profiling by writing
"prof()" command to backdoor socket, once the service (like
neutron-server) finishes expected processing (example finishing API
call), user again writes "prof()" command with file name as argument
to dump the function calltrace stats. Stats file (in pstat format
with user provided filename by adding .prof) will be generated in
For example, to profile neutron server process,
1) echo "prof()" | nc localhost 8002
2) Issue neutron command (or run rally scenarios tests)
neutron net-create n1
neutron port-create --name p1 n1
neutron port-delete p1
neutron net-delete n1
3) echo "prof('neutron')" | nc localhost 8002
where 8002 is the port which we set like below in neutron.conf
We can later print the stats from the trace file like below
stats = pstats.Stats('/tmp/neutron.prof')
The trace file will look like in (for above neutron API calls) .
We use Yappi with context set to greenlet  to profile greenlets.
We can't use GreenletProfiler , which does the same 
1) as it is no more maintained
2) Also compiling yappi source inside GreenletProfiler is failing for