Architectural Breakdown: Generosity Is a Default Setting
 # Zero-Data USB Tether Diagnostics: Why 11 Out of 14 Phones Hit 15 Mbps Until I Found One Setting Eleven phones. Fifteen megabits per second. Exactly fifteen. Not fourteen. Not sixteen. The other three hit 106 Mbps for reasons…
Zero-Data USB Tether Diagnostics: Eleven phones hit 15 Mbps, while three others reached a whopping 106 Mbps. After two hours of frustration, the author decided to build a diagnostic engine from scratch without relying on npm, Node.js, or a 300MB of dependencies. The architecture involved Python, asyncio, collections, dataclasses, and raw subprocess calls.
The author's goal was to measure the throughput of USB tethered devices without wasting resources. Initially, they considered installing adb, spinning up a Node server, and piping throughput data through request with retry logic, aggregating the data into InfluxDB. However, this approach required 50 dependencies and 400MB of RAM, leaving little room for actual measurement.
The author's solution involved writing the diagnostic engine in Python, using only asyncio, collections, dataclasses, and subprocess calls. The key to their approach was minimizing memory usage and avoiding unnecessary allocations. They created a BoundedThroughputEngine class with a circular buffer and Welford's online statistics algorithm, eliminating the need for repeated list() conversions.
To run the tests on multiple devices, the author implemented a USBTetherOrchestrator class that handles USB enumeration, ADB bridge, and concurrency limiting. They used asyncio.Semaphore to limit the number of concurrent tests and asyncio.sleep(0) after each run to prevent event loop starvation. This approach allowed them to measure the performance of 14 devices without deadlocking or resource exhaustion.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.