Page MenuHomePhabricator

Make PhutilChannel::waitForAny more reasonable about detecting unselectable channels
ClosedPublic

Authored by epriestley on Dec 14 2013, 1:24 AM.
Tags
None
Referenced Files
F14000203: D7769.diff
Thu, Oct 24, 8:03 PM
F13990659: D7769.diff
Tue, Oct 22, 5:19 AM
F13982580: D7769.id.diff
Sun, Oct 20, 12:25 AM
F13979705: D7769.id17570.diff
Sat, Oct 19, 5:59 AM
F13975745: D7769.id17576.diff
Fri, Oct 18, 11:26 AM
Unknown Object (File)
Sep 6 2024, 9:40 AM
Unknown Object (File)
Aug 23 2024, 1:32 AM
Unknown Object (File)
Aug 23 2024, 1:32 AM
Subscribers

Details

Summary

Ref T4189. Currently, channel getWriteSockets() methods return only blocked write sockets, and waitForAny() degrades to a busy wait if any channels are missing read and write sockets, assuming the channel is not a socket-based channel.

This means that if you have an unblocked, writable, socket-based channel and a blocked, readable socket-based channel, we always degrade to busy wait immediately.

An example of this occurs during git push:

  • We have one R/W channel through SSH to the git push on the user's computer.
  • We have one R/W channel through ExecFuture to the git receive-pack on the remote host.
  • When the client finishes writing, we close the "R" half of the SSH channel. This leaves it writable, socket-based, and unblocked for most of the push.

Instead, make getWriteSockets() methods return all write sockets, even if they're not blocked, and then ignore them if isWriteBufferEmpty() says we don't need to wait for them.

This is generally cleaner, and fixes several issues:

  1. The ssh-exec process no longer sits in a busy wait between the SSH read channel closing and the operation finishing.
  2. The stdin/stdout/stderr log in the SSH stuff can be simplified (next diff).
Test Plan

Ran git push of the Wine repository, saw nothing we own spend an unreasonable amount of time doing CPU stuff. Added a bunch of logging to confirm things are working reasonably under the hood.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped