unison-fsmonitor icon indicating copy to clipboard operation
unison-fsmonitor copied to clipboard

High CPU/memory usage after main unison process exits

Open rowantran opened this issue 1 year ago • 1 comments

Issue

If the main Unison process exits, e.g. because the SSH connection to the server was dropped, the fsmonitor process continues running and CPU/memory utilization increases dramatically.

When running with debug logs enabled, the following two logs are repeatedly printed after the Unison process exits:

event: Input("")
>> ERROR Unrecognized%20cmd%3A%20

I observed this issue on an M1 MacBook running macOS Sonoma, but I don't believe the issue is platform-dependent.

Reproduction

  1. Configure Unison with repeat=watch and set the destination to a remote server using SSH.
  2. Kill the SSH subprocess, which should cause Unison to exit with a "connection lost" error.
  3. Observe that the fsmonitor process continues running with increased CPU and memory usage.

Proposed Fix

I believe adding an exit statement to the send_error function here should resolve the issue by terminating the fsmonitor process after the first invalid input. We could also do something equivalent, like bubbling up an Error from handle_event and exiting the receiver loop.

This should be consistent with the reference fsmonitor implementation, which exits after printing an ERROR message (link)

I'm not particularly familiar with Rust or the fsmonitor protocol, so wanted to open this issue before opening a PR. But I'd be happy to work on the fix for this issue.

rowantran avatar Jun 27 '24 03:06 rowantran

Having the same issue here. Using version 0.3.4 installed via Homebrew, macOS 14.6.1. (Originally reported this as https://github.com/bcpierce00/unison/issues/1053 but didn't realize this was a third-party version.)

JBYoshi avatar Aug 24 '24 16:08 JBYoshi

Having the same issue with unison 2.53.5 installed via Homebrew on macOS Sonoma 14.7 on M1 pro.

sndnshr avatar Nov 06 '24 02:11 sndnshr

@myhro It seems you made a fix on this. Do you want to submit a PR?

autozimu avatar Nov 06 '24 03:11 autozimu

@autozimu Thanks for following up on this issue. I just submitted #29.

myhro avatar Nov 06 '24 03:11 myhro