Faster ADB tunnel to Manymo emulators

Jun 9/2014, by Pete Schwamb

We're happy to announce a new version of the Manymo Command Line Tool that dramatically improves app upload speed over adb. We've seen large app uploads go from several minutes to seconds.

Code, Build, Test, Repeat

You probably spend a lot of time in the standard dev cycle, which often looks like this:

  • Edit some code
  • Tell your IDE to compile, install, and run your code
  • Test your changes
  • Repeat

Saving time on an individual step of an oft-repeated process multiplies your time savings. Which is why we've invested time into speeding up the upload process when using Manymo.

Waiting for packets.

We analyzed the traffic sent when uploading an app using adb install and found that due to the way the adb protocol works, a large amount of time is spent waiting for ack packets. And because the adb protocol only transmits 4096 bytes at a time, this really adds up over the course of transferring a large app.

The main reason for a protocol to implement a stop and wait approach is for packet ordering and timeouts. Since we're running adb over TCP, we have those guarantees. If we could somehow convice adb to keep sending data while the packets are making their way to the emulator, then we should save a lot of time, and still have a reliable channel.

We looked into updating the 4096 byte limit to reduce the number of packets sent, but that change needs to be reviewed thoroughly and we wanted to help users now.

Fast Ack Middleman

The solution is to have our middleman, the manymo tunnel, to generate a fake ack back to the adb client immediately, rather than waiting for it to make the round trip. Then adb will be able to move on to the next packet quickly.

There are some details we've left out, such as making sure the real ack packets are filtered out, and that this applies to only certain packets that are part of a file stream within the adb protocol. But that leaves the door open for another post about how the adb protocol really works, and how we can use the manymo tool to visualize it.

In the meantime, check out the new version and let us know how it works!

Stay tuned by following Manymo on Twitter and Google+.