-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Re-enable connection retrying on discord connector #24189
Conversation
ed2b2ec
to
48b5fa9
Compare
I've tested this, and it seems to work, but sorry, I can't just not ask...
We're adding a local copy of a 500-line class? For a one-liner change? Which I see basically no reason for upstream to reject (and we haven't even asked if they would anyways)? And so now we're on the hook for maintaining this code and keeping it up to date with upstream too, with the one-liner on top? It's a little baffling if you ask me. Maybe upstream will take a while to merge that but it's not like this is a life-or-death change? Like sure, we've done similar things with humanizer, but that's because humanizer upstream is practically dead (no new releases in 1.5 years, very few actual changes on master, issue triage is basically nonexistent). I know we've been increasingly on the "roll your own" train as time goes on but this feels like pushing it. |
I'll PR the change upstream but have little hope as the library has not been updated in years. |
Upstream PR submitted: Lachee/discord-rpc-csharp#237 |
48b5fa9
to
a6b1559
Compare
I've force pushed this with a package update rather than local implementation (see Lachee/discord-rpc-csharp#237). |
The package update is nice and all, but you also force-pushed the part that was disabling the retry mechanism out, too. I brought it back in 17aac06. Probably worth a go as to how this behaves in the wild... |
We disabled retry logic in #7332 due to reported overheads (in stable), as a precautionary measure. I've revisited this (triggered by this report) as it's pretty bad not having any kind of retry logic.
Over 5 failed connection attempts:
Note that this is running time, not all time. It does not include actual
Thread.Sleep
sleep time, and the overhead seen here is actual CPU time being used.Of note, the implementation of
NamedPipeClientStream
has some egregious use ofSpinOnce
:https://github.com/dotnet/runtime/blob/d59af2cf097acb100ad6a9cba652be34be6f4a2e/src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.cs#L151-L155
This adds perceivable overhead to the connect process, which we really don't want on a background thread.
To get around this, I've made a local copy of
ManagedNamedPipeClient
(https://github.com/Lachee/discord-rpc-csharp/blob/master/DiscordRPC/IO/ManagedNamedPipeClient.cs) and adjusted the connect timeout to 0, removing this overhead completely.Tested on macOS and windows.
When testing, this diff can be used to enable console log output: