Closed sajith closed 1 year ago
Of the below lines, I think lines 124-125 are not necessary at all, because the subsequent Queue.get()
is a blocking call -- it will block until there's an item in the queue (there's also an alternative Queue.get_nowait()
).
When running sdx-controller on a laptop, my CPU is struggles, the laptop starts to heat up, and the fan spins noisily. I think the busy loop is the problem. I did some profiling with scalene, like so:
$ pip install scalene
$ python3 -m scalene --cpu-only -m swagger_server
# Wait a while and then stop the processes
^C
Scalene reports that most of the Python time is spent in that busy loop.
It gets better without that loop:
Did some tests on the testbed (publishing topologies, requesting a connection, etc). It worked fine. This doesn't seem to break anything. :-)
Issue is #33. These lines seem to cause high CPU usage:
https://github.com/atlanticwave-sdx/sdx-controller/blob/82dca910e94d337c8877b9b695305bcdb1096d9d/swagger_server/__main__.py#L124-L125