Some Bits: Nelson's log

11 posts in June 2014

Remote file system bad display (MacOS sucks)

Finder’s access to remote filesystems will sometimes show stale data. I’m copying a 2.5GB file to an SMB share (Linux samba). While copying I look at a folder, then click the little down arrow to open the subfolder in the window. It shows no contents, it must be an empty folder! So go to delete, and then it pauses saying “deleting 5 items”. Ha  ha, joke’s on me. Cancel the delete, try again. This time wait 3–5 seconds for the file content to list, and poof there are the files now. At least I cancelled the delete in time.

I’m not complaining that the remote filesystem is slow, particularly when a big copy is happening. No. I’m complaining that Finder is showing incorrect information.

 

Some quick ad campaign stats

I ran some simple ads to promote Logs of Lag, my League of Legends netlog parser. I’m having a hard time getting attention and thought it’d help to get a bit of paid traffic. I invested, oh, $20 in all of this, trying to bottom feed some traffic. Results after a week or two of trying:

Google Adwords

0.18% CTR. 4468 impressions, 8 clicks, $2.73

Screen Shot 2014-06-26 at 2.03.14 PM

Very bad results, particularly on the search ads. Google’s minimum bid for a relevant keyword like [league of legends lag] seems to be at least $1, and apparently Google is happier showing no ads than showing cheap ads. 4339 of the impressions were via the Display Network. Near as I can tell AdWords gives me no way to see where those ads actually displayed. Bummer.

Bing Ads

0.59% CTR. 848 impressions, 5 clicks, $0.17

Straight-up clone of the Google ad campaign. But Bing Ads is quite happy to show ads for $0.10 CPC, so the good keywords I wanted got some impressions and clicks. No display ads at all; not sure if I wasn’t eligible or there was just no inventory.

Twitter Ads

Too early to tell. But my ad is a poor match for Twitter. All you can promote is a tweet, and I didn’t want to write a special ad tweet for my website. Also hard for me to imagine a Twitter user will be inspired to try my tool by a Twitter ad, particularly on a mobile device. I think Twitter Ads may be better suited for brand campaigns.

Reddit Ads

0.94% CTR, 14030 impressions, 132 clicks, $10.

Screen Shot 2014-06-26 at 2.11.33 PM

 

By far the most successful of my ads. In part because I could target it so specifically to /r/leagueoflegends, a big community. Also Reddit ads are cheap. It’s a pretty interesting ad product really, particularly the way ads become stories that get Reddit votes, comments, etc. I’m surprised it’s not better known. Reddit has a blanket $0.75 CPM rate which seems fairly cheap to me, particularly given the value of Reddit’s audience. The ad tool sure is primitive though. I’m left wondering why Reddit doesn’t pursue an ads business more aggressively.

Conclusion

Small ad campaigns are cheap. OTOH I didn’t set up any way to measure actual conversion. What I want is to get my tool in people’s minds so they remember to try it a month from now, and I’m not about to do the necessary work for such a small side project of mine. I don’t regret the $12.90 I spent though. I’d definitely go back to Reddit ads to get attention for something there, particularly if the organic way of getting Reddit attention doesn’t work out.

 

Directory symlinks (MacOS sucks)

Try this on a Mac

cd /tmp
ln -s ~/Docum <press TAB>
ln -s ~/Documents/ .
ln: ./: File exists

Trollface

 

Yes, MacOS “ln” is too stupid to understand that if something has a trailing slash you probably meant to symlink the directory with that name, not the implicit “Documents/.” name. And bash completion is just helpfully providing slashes because 99% of the time you want them when talking about directories. Of course this works fine on Linux; another legacy of MacOS being based in SysVile.

(To be fair the with/without trailing slash thing has always been ambiguous in Unix. rsync even assigns different semantics to the two names, confusing me every single time.)

 

Steam (MacOS sucks)

The Steam client on MacOS has always been terrible. I mean it’s badly designed as a product, but then also the implementation is terrible. Basically it’s 90% just showing a web page, but that’s always been slow and cranky and broken.

But today takes the cake. Because running Steam has brought my whole system to its knees. Beachball cursors, 10 second delay switching apps, 20 second delay to launch Console.app. Total trash. And as bad as Steam is, the real blame falls on MacOS for freezing because one app is badly behaved. I don’t see anything obviously wrong running top or activity monitor. Is the graphical shell single threaded or something? Steam wasn’t even doing much, just sitting there showing me a web page and downloading an update in the background.

To be fair, I think part of the problem was memory. When I killed Steam and relaunched it a bunch of memory freed up and things are better. So maybe that’s a Steam bug afterall. No Unix kernel schedules memory contention well.

 

 

ToS/DSCP byte in IP packets

Update: be sure to read comment #3 below from Dave Täht. Apparently the Bufferbloat project has made a lot of progress on good router queuing and there’s a lot for me to learn about, including fq_codel and CeroWRT.

Interesting thing in Transmission’s Bittorrent client’s docs

peer-socket-tos: String (default = “default”) Set the ​Type-Of-Service (TOS) parameter for outgoing TCP packets. Possible values are “default”, “lowcost”, “throughput”, “lowdelay” and “reliability”. The value “lowcost” is recommended if you’re using a smart router, and shouldn’t harm in any case.

The Type-of-Service byte is the second byte in an IP header. It is not widely implemented, and has a tangled history. Is it useful?

The bottom six bits are for DSCP, Differentiated Services (aka DiffServ). This allows an IP packet (or the program controlling it) to request a certain level of routing service quality. There’s various things to request; low jitter, best effort delivery, and a couple of means of defining priority classes. I don’t know how well supported these bits are, the Wikipedia entry makes it sound like it’s not entirely unknown. Linux IPTables has rules for setting DSCP classes. The Bufferbloat wiki has some discouraging notes on implementation. Windows 7 claims to support it, but looks wonky. Someone found a Comcast bug in their DSCP data that was harming download speeds.

The top two bits are used for ECN, a way for the router to signal to a TCP stack that it should slow down without actually dropping packets. I think ECN is not practically useful in today’s Internet, too many clients don’t implement it and too many routers don’t use it (or any form of queue management). But I could be wrong. /proc/sys/net/ipv4/tcp_ecn is 0 (not enabled) in my Tomato/Shibby router even though I’ve turned QoS on.

My conclusion on a quick read is these bits are not usefully deployed, too much stuff doesn’t support them. Too bad; it’s exactly what a home network router needs to cooperatively share a network. So much of TCP/IP QoS work was abandoned because it doesn’t work with hostile peering relationships. But I really do trust and control my home router and I wish it could do more to manage bandwidth.

Logs of Lag ready to go

My Logs of Lag site is ready to launch. It works well, a clean and simple way to drop a League of Legends logfile onto a web page and see some statistics.

Not sure how to properly “launch” this yet. Success would be some visibility on the League of Legends Reddit, I’ll probably post it on Monday but it’s a crapshoot of the first 15 minutes whether it gets upvotes or not. I don’t expect an amazing response, this kind of tool is really something more useful to hang around and be available for months or years when people need it.

I’m pretty happy with how the final project came together. I was worried for a long time about the visual style. I still don’t think it’s great, but adding a basic background image texture and switching the fonts from Helvetica/Arial made a big difference in making it feel “real”. And I don’t want to do the over-produced glitzy graphics thing that’s popular with most gaming sites, I find that a useless distraction.

Ideas for future features:

  • Highlight “bad” data. Ie; if the loss/second is greater than some threshold, make that show up in big angry red warning font. I want to collect some logfiles from users to see what is typical before building a classifier.
  • Parse broken logs. In particular the logfile gets wonky if the game disconnects, would be nice to parse that correctly.
  • An analyzer for a whole directory of files. This is the way lolparse.com works, presenting summary statistics for gameplay in many games. It’d be useful to characterize lag for many games as well. Totally feasible given all the work is client-side, it could be fast. A histogram showing the distribution of median ping and median packets/s loss would be a good start.

And ideas for the server:

  • Replace the Python CGI with a real server. I have a Node version but I’m not sure I like Node. Porting the CGI to Gunicorn would suffice for scaling.
  • Or.. Remove the server entirely. Just make the client Javascript upload stuff to S3.
  • Or.. commit to a real server, and add logins and user data management.

D3js mouseover tooltip

It took me three hours, but I added a mouseover tooltip to my LoL netlog graphs. It turns out there’s three ways to do this.

  1. Use svg:title or svg:text and rely on the default browser hover action to show it. Totally ghetto, but it does work.
  2. Catch mouseover events on your actual chart elements. If you bound your data sensibly, the event handler gets the datum that was bound to the element that got the event passed right to it. This works great for bar charts as long as you don’t mind the popups only showing up on the bars, not the whitespace. Not so good for line charts or other things.
  3. Add an overlay to the entire chart area you want to capture events in. Unfortunately no useful data is bound if you do this. So you have to use d3.mouse() to get the relative X,Y in pixels of the mouse position, then shove that through scale.invert() to map that back to data space. Here’s a demo of that technique. It’s a lot more work, but now you have mouse events for the whole chart area, not just the marks.

I went for option #3 and really it looks pretty great. The other tricky part is I was reading the timestamp from the X axis of my time series chart, but then finding the specific row of timeseries data that corresponds to that timestamp is not so easy. I ended up doing a linear search in my data array; not awesome, but will work OK for me.

The other half of the problem is displaying the tooltips. I ended up going with a div element with visiblity toggled by mouseenter/mouseleave. The tooltip is positioned absolutely with CSS, and the mousemove handler positions the tooltip relative to the event pageX and pageY. Important to make sure the tooltip div doesn’t grab the mouse events. I did that with positioning, but probably better to use the pointer-events CSS option.

 

Uncommon ASCII control code delimiters

So much code is worried about using “safe” delimiters, and quoting, and the like. I’m probably getting myself in trouble, but I just used a very old school ASCII delimiters in my code.

In particular I’m using ASCII 28 (File Separator), aka U+001c (Information Separator Four). This is one of the ASCII control codes for separators that’s mostly a forgotten thing. I’ve often wondered why we have CSV and TSV files instead of files delimited by ASCII 30 (Record Separator), too. That character is way, way less likely to occur in source input than a comma or a tab.

I hope I’m not getting myself into trouble somehow. My use case is the LoL netlog files, in particular I want to concatenate a JSON blob and the raw text logfile together to POST to a web server. The source data is very, very unlikely to contain any non-printable characters, including U+001c. If it does I’m screwed.

Javascript code to emit this

    var uploadText = [JSON.stringify(parsedLog),
                      '\n\u001c',
                      rawLog.substring(0, 1000000)].join('');

And Python to parse it (in a CGI)

try:
    jsonText, rawText = postdata.split(u'\u001c')
except:
    jsonText = '{&amp;amp;amp;amp;amp;amp;quot;valid&amp;amp;amp;amp;amp;amp;quot;:false}'
    rawText = postdata

Update: there’s now a draft IETF spec to use RS to separate JSON blobs to make it easier to stream-parse big wads of JSON data.

San Francisco ISP woes

I love my ISP, sonic.net. They have solid no bullshit service, great customer support, and are generally super consumer friendly. Unfortunately they are DSL over AT&T’s copper, so they are pretty hamstrung with what they can do. And I’m stuck at 7Mbps on a single line.

I tried calling them to upgrade to bonded service and it gets very expensive very quickly. Their business service is the bonded option but it’s $90/mo for what will probably be 15Mbps for me (30 if I’m lucky with line quality). And then it comes with two phone lines I don’t want for which I have to pay another $40/mo in taxes, no choice. I assume that bundling is because Sonic is making some money just for providing phone service, but who knows.

In SF we have other technology options. MonkeyBrains offers high speed wireless, which I don’t want. Comcast and Astound offer cable Internet and are promising 50Mbps or even 110Mbps for less than sonic.net wants to charge me. But Comcast is the devil. Maybe Astound is an option. Reports from friends are both have been reliable ISPs.

I called Astound. It’s $90/mo, no taxes, for 100/5 cable Internet. (That’s the price after the first year discount.) They provide service over their own coax, not sharing cable with Comcast.

 

Reconsidering Node

Having done a bit of work deploying a Node server I may not use it afterall. Things I don’t like:

  1. Lack of standard production scripts
  2. Lack of blanket error handling for servers; exceptions kill servers
  3. Difficulty preventing memory leaks in servers. Closures capture memory in complex ways and V8 isn’t always able to GC it.

These are all solvable problems, but I’m not sure I want or need to solve them for my very simple server. The main advantage I get from Node is that I can share some Javascript parsing code between the browser and the server. But I’m not sure I really need that.

Truthfully I don’t need much if any custom server code at all. Just a bucket to post data to and be able to retrieve it again. I wonder if I can do that entirely with client-side Javascript and some basic S3 API.

 

Starting a Node server in Ubuntu

My Node server sort of works and I’m ready to put it into production. I need some sort of start script. What to do? Naturally, the Node world has to reinvent everything and there’s no standard way to do this. But most docs talk about using Upstart (the Ubuntu variant of init scripts), plus monit or forever to keep the Node process running when it inevitably crashes. (Because of course, this is new tech, it’s gonna crash!).

Also some scary notes about catching exceptions globally so your server doesn’t fail simply because of a bug in one user request, but I think Express takes care of that me. Update haha joke’s on me, by default the whole server crashes if you have an unhandled error because “By the very nature of how throw works in JavaScript, there is almost never any way to safely pick up where you left off, without leaking references, or creating some other sort of undefined brittle state.” Apparenly Node domains are the way to deal with this, some notes here.

I ended up just using a trash shell script for /etc/rc.local because it’s too much bother to do it right. I wish that here in 2014 we finally had a basic simple standard way to deploy and run server scripts in production. So many solutions that are either too ad hoc (upstart) or too complex (Puppet and friends)

Some resources: