Some Bits: Nelson's log

6 posts in August 2014

Pie chart alternative

Pie charts are bad; they’re hard to read, particularly for small percentages. This Pornhub Insights report (SFW) has an interesting alternate type of pie chart.

pornhub-traffic-mobile2The angle of each wedge is constant, 360°/5 = 72° in this graph. It’s the radius of each wedge that conveys the data. In other words it’s basically a bar chart, but turned into a circle. That’s a nice compact layout. And it visually conveys that the numbers sum to 100%. If I measure this right the wedge radius is proportional to the square root of the value, so that the wedge area is proportional to the value. That’s more correct for visual perception. It also works well for showing a 40:1 ratio like the data above; in a linear bar chart the 1% data would only be a couple of pixels high.

I’m sure Pornhub didn’t invent this, but it’s a neat technique I haven’t picked up on before.

Update: Mike B tells me this is called a Polar Bar Chart. Or a Coxcomb chart, after no less than Florence Nightengale.

youtube-dl rate limiting bumpiness.

The results of using youtube-dl to download at 50 kbytes/second:

Screen Shot 2014-08-28 at 9.22.15 AM

Basically it uses max bandwidth for a bit, then stops. The average rate is indeed 50 kbytes/sec, but it’s 1 second of 300 kbytes/sec (max rate) followed by 6 seconds of none. Not exactly the intended effect.

I’m not clear on how much a user-space app can even do to throttle bandwidth on a TCP socket like this. I’d assumed they were stalling the pipe, only reading 60 kbytes/second, and the server is filling the pipe and something’s buffering. But that graph looks more like youtube-dl reading the whole buffer all at once, then sleeping a long time.

The code looks like it’s doing something reasonable. If I understand the main loop right, it reads block_size bytes (1024), then sleeps for a carefully calculated amount of time to maintain the rate. So it’s at least trying to read little bits in short intervals, I wonder why it’s not working? I should test it on a faster network and see if it does the same weird thing.

 

League of Legends game protocol

I continue to be interested in understanding League of Legends lag. It’s a custom UDP protocol, so the usual way of measuring TCP packet loss doesn’t work.

I realized today the game must have something like a sequence number in the protocol. Apparently the LoL protocol is based on ENet, an open source “reliable UDP library”. There’s no dissector for ENet included in Wireshark but Google searches suggest several people have written them. packet-lol also has a LoL dissector but it is a couple years old, no idea if it’s still valid.

I’ve been hanging out on Freednode ##loldev recently, a nice little IRC channel. One thing they’re working on is documenting the observer protocol on a GitHub Wiki. But apparently that’s a totally different protocol from the UDP live game, based on HTTP requests for 30 second chunks of the game as well as keyframes, etc. A fair number of third party tools use the spectator protocol, sites like riftwalk.gg are doing some great game analysis. Neat stuff, but not relevant to the lag experienced while playing the game.

Here’s a big stack of links I’ve collected relevant to LoL protocols.

netconsole

I have a headless Linux box and every time I reboot it there’s a several minute anxiety where I don’t know if it’s working or not. (I reboot only every year or so, I think fsck’s timer kicks in and it takes awhile.)

I want to see the console while its booting, without a monitor. I don’t want to fuss with serial cables. Netconsole looks like an option; kernel module that sends UDP log messages via a pre-arranged MAC address. Before the TCP/IP stack is initialized. Docs: Ubuntu, Arch, kernel.

SMART errors: living dangerously

My once-yearly look through root’s mail on my home server reveals errors from smartd

Device: /dev/sdb [SAT], 17 Offline uncorrectable sectors
Device: /dev/sdb [SAT], 17 Currently unreadable (pending) sectors

The error started 14 May 2014 10:57:07 +0000 at 5 errors, then jumped to 17 two hours later and has stayed at 17. It’s just a backup disk, so I’m going to live dangerously and see what happens. The disk is 2.5 years old and has a three year warranty.

Possibly related, rsnapshot hasn’t run cleanly in weeks and I didn’t notice because errors go to a local mail spool I never check. I should rethink that.

 

MacOS dd timings

I need to clone a 2TB USB disk on my Mac. Going to use dd. What’s the right block size?

The bigger the better, apparently, but there are diminishing returns. “bs=128k” is good; reading from USB and writing to /dev/null that gives me 38Mbytes / second, which IIRC is about the rate for a 5400 RPM disk. 16384 gives about 20Mbytes / second. The default 512 byte blocks gives 1.2Mbytes / second.

I love that the default is 30x slower than maximum. The legacy of SysV’s 512 byte disk blocks is never going to end.

$ dd if=/dev/rdisk2 of=/dev/null bs=128k count=10000 skip=1m
10000+0 records in
10000+0 records out
1310720000 bytes transferred in 34.233990 secs (38287094 bytes/sec)

Update: that was for timing disk reads. Disk writes were slower, a test copy from one USB disk to another on my iMac showed 17 MB/s, which would take 32 hours to copy a 2TB disc. I thought at first that was because writes are slow but then I remembered the iMac is USB 2.

My Linux box has USB 3 and can read the disk at 100 MB/s. Shouldn’t have trusted my memory about disk speeds! And a copy from disk to disk on my Linux box is showing 117 MB/s, or about 5 hours to do the copy. Bonus: I trust Linux not to be doing something weird behind my back with the disks.

The full 2TB copy ended up taking about 6.5 hours, for an average rate of 85 MB/s. I forget slow the end of a disk is.