diff options
author | Josh Gao <jmgao@google.com> | 2019-03-01 10:15:54 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-03-01 10:15:54 +0000 |
commit | 7669ea5a44563d7ceebb2adcb03838b57051a601 (patch) | |
tree | d1d0a54fb7da07e1f6776c6731d9eb71083a4470 | |
parent | 83d9b680f5f9691a81b999f2430bf7847397a8b3 (diff) | |
parent | 5841a96afcca45380af5233f335f6df2bdecfc64 (diff) |
Merge changes I4d351f56,Ib9e91157
* changes:
adbd: tune USB read/write sizes and queue depths.
adb: add benchmarks for sink/source.
-rwxr-xr-x | adb/benchmark_device.py | 39 | ||||
-rw-r--r-- | adb/daemon/usb.cpp | 8 |
2 files changed, 43 insertions, 4 deletions
diff --git a/adb/benchmark_device.py b/adb/benchmark_device.py index e56ef5a55..4d0cf49a0 100755 --- a/adb/benchmark_device.py +++ b/adb/benchmark_device.py @@ -17,6 +17,8 @@ import os import statistics +import subprocess +import tempfile import time import adb @@ -56,6 +58,41 @@ def analyze(name, speeds): msg = "%s: %d runs: median %.2f MiB/s, mean %.2f MiB/s, stddev: %.2f MiB/s" print(msg % (name, len(speeds), median, mean, stddev)) +def benchmark_sink(device=None, size_mb=100): + if device == None: + device = adb.get_device() + + speeds = list() + cmd = device.adb_cmd + ["raw", "sink:%d" % (size_mb * 1024 * 1024)] + + with tempfile.TemporaryFile() as tmpfile: + tmpfile.truncate(size_mb * 1024 * 1024) + + for _ in range(0, 10): + tmpfile.seek(0) + begin = time.time() + subprocess.check_call(cmd, stdin=tmpfile) + end = time.time() + speeds.append(size_mb / float(end - begin)) + + analyze("sink %dMiB" % size_mb, speeds) + +def benchmark_source(device=None, size_mb=100): + if device == None: + device = adb.get_device() + + speeds = list() + cmd = device.adb_cmd + ["raw", "source:%d" % (size_mb * 1024 * 1024)] + + with open(os.devnull, 'w') as devnull: + for _ in range(0, 10): + begin = time.time() + subprocess.check_call(cmd, stdout=devnull) + end = time.time() + speeds.append(size_mb / float(end - begin)) + + analyze("source %dMiB" % size_mb, speeds) + def benchmark_push(device=None, file_size_mb=100): if device == None: device = adb.get_device() @@ -110,6 +147,8 @@ def benchmark_shell(device=None, file_size_mb=100): def main(): device = adb.get_device() unlock(device) + benchmark_sink(device) + benchmark_source(device) benchmark_push(device) benchmark_pull(device) diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 83ff221cc..ff618b050 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -57,11 +57,11 @@ using android::base::StringPrintf; // We can't find out whether we have support for AIO on ffs endpoints until we submit a read. static std::optional<bool> gFfsAioSupported; -static constexpr size_t kUsbReadQueueDepth = 16; -static constexpr size_t kUsbReadSize = 16384; +static constexpr size_t kUsbReadQueueDepth = 32; +static constexpr size_t kUsbReadSize = 8 * PAGE_SIZE; -static constexpr size_t kUsbWriteQueueDepth = 16; -static constexpr size_t kUsbWriteSize = 16 * PAGE_SIZE; +static constexpr size_t kUsbWriteQueueDepth = 32; +static constexpr size_t kUsbWriteSize = 8 * PAGE_SIZE; static const char* to_string(enum usb_functionfs_event_type type) { switch (type) { |