amphp/parallel-functions

Massive CPU usage

theofidry opened this issue · 6 comments

Hello.

I noticed two things when killing a command using parallelMap:

  • Although the main process was killed, none of the workers were. As a result they well all taking 100% of the CPU in the background
  • When killing the process one by one, the freed CPU was taken right away for the other workers. So when only one worker was remaining, it was taking 100%. I can't check atm but I suspect it's because it's polling like crazy and don't do any sleep of any kind.

I appreciate this may not be the appropriate repo on which opening the issue, this issue is more to notify you on the issue and not forget about it. So maybe opening two separate issues in the right repo may be needed later

Yes, we noticed that one, too. It relates to amphp/byte-stream#40.

@theofidry Are you on macOS?

@theofidry I recently pushed a change that addressed amphp/byte-stream#40, which primarily affected macOS. Can you try again with v1.3.1 of byte-stream (without ext-uv, as there's an issue with closed streams and watchers that needs to be fixed in that loop).

byte-stream 1.3.1 fixes the issue on my side at least 👍 I can't talk for the CPU usage, but at the processes are now properly killed once the main process is killed.

Thanks for confirming!