Homec4science

Make PhutilChannel::waitForAny more reasonable about detecting unselectable…

Authored by epriestley <git@epriestley.com> on Dec 15 2013, 21:52.

Description

Make PhutilChannel::waitForAny more reasonable about detecting unselectable channels

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.

Reviewers: btrahan, zeeg

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4189

Differential Revision: https://secure.phabricator.com/D7769

Details

Committed
epriestley <git@epriestley.com>Dec 15 2013, 21:52
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU59114868de66: Dramatically improve subprocess I/O for large buffers
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHUc2c800dcd0e3: Make PhutilChannel::waitForAny more reasonable about detecting unselectable… (authored by epriestley <git@epriestley.com>).Dec 15 2013, 21:52