I was getting wildly inaccurate transfer speed values reported by the Backblaze B2 library I am using. I dug into it, and I suspect that, on Linux at least, the Stopwatch class (provided by .NET) is under-reporting short durations. The library is using Stopwatch to capture the time each write operation takes, so this makes it think the operation takes less time than it actually does and is thus faster than it is. But it's coming through way faster. I just watched it take about 2 minutes to upload a 28 MB file (not terribly impressive), and the entire time it was telling me the transfer rate was over 10 MB/sec!
So, I went upstream to that library's code, which is on GitHub, and reworked it to use a rolling average instead of computing the speed individually for each write operation. In the process, the timestamping is reworked so that it is not possible for it to be under-reported. I have submitted my changes for consideration by the package's authors: https://github.com/microcompiler/backblaze/pull/28
I don't have a way to see it in action just yet, because I've got an upload operation running that looks like it might actually run through to completion this time, and it's already uploaded 9 GB, and the only way to switch to the new Backblaze library would be to restart it. I don't want to do that!
No comments:
Post a Comment