Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch PluginFrontend to domain sockets on macOS #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bell-db
Copy link
Contributor

@bell-db bell-db commented Sep 23, 2024

What changes are proposed in this pull request?

Fixes #379 by switching from TCP sockets to Unix domain sockets with server-side read timeout on macOS.

It turns out extremely difficult to find a reliable way to IPC on macOS, when the client is a simple bash script without accessing to mature frameworks. None of the above survived a stress test of 100k runs of 100KB messages:

However, when trying to implement a retry-on-timeout, it's found that, mysteriously, domain sockets with junixsocket server are working well with a server-side read timeout alone, even if we don't catch and retry (i.e. there is no timeout exception thrown or hang anymore). It's also the most performant solution on macOS:

Implementation OS [1] Short Message Roundtrip Latency (ms) 100KB Message Roundtrip Latency (ms) Known issues
Named pipe macOS 31.13 33.31 Missing EOF. Out of 100k runs: 70 timeouts
TCP socket (Java applet client) macOS 80 83 Port conflict. Out of 100k runs: 10 timeouts, 26 empty responses, 8 Bad Request
TCP socket (netcat client) macOS 16.06 17.77 Port conflict. Out of 100k runs: 8 timeouts, 20 empty responses, 4 Bad Request
Domain socket (netcat client) macOS 14.64 16.28 nc with domain sockets / junixsocket missing EOF (w/o server read timeout). Out of 100k runs: 2.5k timeouts
Domain socket (nmap ncat client) macOS   30.7 junixsocket missing EOF (w/o server read timeout)
Domain socket (socat client) macOS   20.1 junixsocket missing EOF (w/o server read timeout)
Domain socket (Perl client) macOS 24.94 25.52 junixsocket missing EOF (w/o server read timeout)
File + signal macOS 27.65 29.80 Signal conflict when multiple generators
Named pipe Linux 3.74 5.90 None (Passed 100k runs)
TCP socket (Java applet client) Linux 3.96 5.63 None (Passed 100k runs)
TCP socket (netcat client) Linux 1.82 3.67 None (Passed 100k runs)
Domain socket (netcat client) Linux 1.83 3.59 None (Passed 100k runs)
File + signal Linux 45.13 48.27 Signal conflict when multiple generators

[1]
macOS: macOS 14.6.1, M2 Max
Linux: Ubuntu 20.04.6 LTS, Xeon(R) Platinum 8375C

How is this tested?

Passes the stress test in #382, after adding client.setSoTimeout(60000).

@bell-db bell-db marked this pull request as ready for review September 24, 2024 00:27
mbland added a commit to mbland/rules_scala that referenced this pull request Oct 1, 2024
Added a couple more repo dependencies to targets under //test.

However, `bazel test //test:all` is a bust for now, because the
protoc-bridge mechanism hangs on macOS:

- scalapb/protoc-bridge#366
- scalapb/protoc-bridge#367
- scalapb/protoc-bridge#379
- scalapb/protoc-bridge#380

Though scalapb/protoc-bridge#366 suggests that it only hangs
occasionally, it's hanging 100% of the time for me on macOS 15.0 on a M3
Max.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sockets aren't 100% reliable on macOS
1 participant