anystack-sh/porter

Porter watch uses 100% CPU

Closed this issue · 2 comments

dpslwk commented

The watch command is using a full CPU core, looks like there is a tight while loop with no sleep or blocking call inside

$porter status --all
+-----------------+--------------------------+---------+---------------------------+
| App             | Process                  | Status  | Description               |
+-----------------+--------------------------+---------+---------------------------+
| cryptodash      | cryptodash-horizon       | RUNNING | pid 37619, uptime 0:01:47 |
| cryptodash      | cryptodash-mix           | RUNNING | pid 37620, uptime 0:01:47 |
| cryptodash      | cryptodash-schedule      | RUNNING | pid 37621, uptime 0:01:47 |
| porter          | scheduler                | RUNNING | pid 37622, uptime 0:01:47 |
| porter          | watcher                  | RUNNING | pid 37623, uptime 0:01:47 |
+-----------------+--------------------------+---------+---------------------------+

form top

PID    COMMAND      %CPU TIME     #TH    #WQ  #PORTS MEM    PURG   CMPRS PGRP  PPID  STATE
37623  php          99.3 02:52.48 1/1    0    15     37M    0B     0B    37623 37607 running

Hi @dpslwk
Are you 100% sure it's the watcher, as the process PID doesn't match the results from the top command?

dpslwk commented

37623???

yup, checked even running it separate, i.e not under supervisor

These first few lines in the command are I think the issue, none of this is block so its just a tight loop

while (true) {
if ($watcher->isRunning() &&
$path = $watcher->getIncrementalOutput()) {

sticking a quick sleep(100) in the while loop and the issue went away, just not sure if that's the best solution or if there's some better blocking method that could be used