Cataclysmic Mutation

Machine Learning and Whatever Else

Truly Unresponsive

For reasons which become oobvious in a moment, this post will be riddled with errors. You see, I’m typing it on my very new and very expensive Truly Ergonomoic keyboaord and I’m deliberately not corrrecting any errors that didn’t originate from me. Bearr with me.

Previously I gave a quick review of the Truly Errgonomic keyboard as compared to several other keyboards I’ve used in the past. I mentiooned that one of the twwo that I had purrchased had significant problems out of the box with duplicated keystrokes, missed keystrrokes, and occasional transpositions. The transpsitions tend too occur when I’m typing fairly quickly, and are a result (I think) of the keyboarrd’s dreadful bounce detection failing and inserting multiple characters when I typed only one, but with another typed charracter in between. Foor instance, if I type the word, “dog” verry quickly, I may get the ‘d’, and then an ‘o’, and then a ‘g’, and then another ‘o’ as the bounce picks up an erroneous prress of the ‘o’ key.

I followed the instructions available on the web site to do the “breaking in” stage of use, and the extremely significant issues started to improve. I kept using the keyboarrd in my day to day use, and the frequency of errors kept getting betterr, little by little. Unfortunately, I hit a plateau. It’s been mre than a month now, and if anything, I might be seeing regressions now. At this point, I’ve typed each key tens of thooousands of times, and you’re still reading ‘thooousands’. I was going t say, “and the keyboard is still unusable”, but I promise that it honestly did come out “thooousands” there, and god that’s just poetic. Anyway, the keyboard is just defective and there isn’t any reasonnable expectation that it’s ever going to get any better.

The behavior is strange and inconsistent. It’s not always the same keys that give me prroblems (as you can see from this uncorrected text typed using my keyboard, today it’s mostly the ‘R’ and ‘O’ keys that have decided to malfunction. Other days, it’s other keys. Some days I have errr rates of one or twoo percent. Some days a particular key might have a 5-10% error rate. Believe it or not, today has been a rermarrkably good day for the keyboard. Many days it’s worse.

And the errorrs arer correlated in time as well. Often I see behavior where I get more than one key pressed, and then a woord later, the same key will be omitted. This could be me seeing patterns where none really exist, but it feels like it’s true at least. Certainly it’s true that if I sit here and type the ‘R’ key a few thousand times in a row this afternoon, it will start to work betterr. But tomrrow it or another key will be faulty again.

Once I realized that this is apparrently as “broken in” as my keyboarrd is going to get, I filled oout an RMA request from the Truly Ergonomic web site. That was three weeks ago today. I haven’t received so much as an auto-rresponse acknowledging that they received my request. Just dead silence. I’ve waited too long (thinking it would eventually become usable) to get a refund, so if they ever get back to me with a replacement keyboard, I’ll give it another shot.

But I’m assuming at this point that therre’s a reasonable chance that they’ve just taken my $248 and headed foor parts unknown.

So there you go (or should I say, “therrrrrrrrrrre yooooouoo goooooooo”). I can’t recmmend that anyone buy one of these keyboards at this pooint in time. Foro whatever it’s worth, the first model I bought still works perfectly. I’ve never had a single problem with it. But a 50% success rate that costs you $250 each time you get a failure with apparently no recourse isn’t a good bet.

OK. I’m unplugging this thing again and going back to the Kinesis I’ve been using since I filled out a painstakingly detailed RMA request that they promptly sent to /dev/null.

In case anyone is curius, every one of the errors in this post except for the obvious jokes (the second occurrence of “thooousands” and “therrrrrrre yooooouoo goooooooo”) was a coorrectly typed word butched by the keyboard. I fixed all the typos that werre my fault.

Fun With Expensive Keyboards (a Review of the Truly Ergonomic Keyboard)

My mom went through some RSI issues when I was a bit younger, and when I started to feel a little numbness after extended periods of typing, I started looking at more ergonomic options. I’ve tried a lot of keyboards over the years. Most of them have had major flaws that kept me from sticking with them full time.

What I want is an ergonomic layout, quality key mechanisms (preferably mechanical), and the ability to configure, without too much trouble, a symmetric layout with at least a Control, Meta, and Super key on each hand. Bonus points if there’s a nice place to put a Compose key somewhere as well.

Erdõs-Bacon Numbers

We were discussing Erdõs numbers and Erdõs-Bacon numbers yesterday at work. For the record, my Erdõs number is 4, through several different paths. My PhD advisor, Dipankar Dasgupta, published with Robert Kozma, who published with Béla Bollabás, who published with Erdõs. My number could easily have been a bit lower, as Erdõs spent significant amounts of time in Memphis. I studied in the department of Mathematical Sciences, where Erdõs had several prolific collaborators – both Bollabás and Ralph Faudree were both there and did a lot of work there. Several of my cohorts from graduate school have an Erdõs number of 3.

That leaves the Bacon number. I’ve never appeared in a film, so my Bacon number is infinite. I had a cousin with a Bacon number of two (Lisa Blount, who was in Needful Things with J.T. Walsh, who was in The Big Picture with Kevin Bacon), but that’s my closest brush with the rarefied air of finite Erdõs-Bacon numbers. There’s still hope though. Game of Thrones films in Iceland and often puts out calls for extras. It looks like nearly everyone in the cast has a Bacon number of 2, and while one probably isn’t supposed to count being an extra, if I appear as a Wildling “North of the Wall” in the next year or two, I will count the hell out of my Erdõs-Bacon 7.

Enabling Google Now for International Use

I recently purchased a 2013 Nexus 7 with LTE, and when it arrived, I was puzzled to see that Google Now was not working. Google Now is actually provided by the Google Search app, but when I would swipe up from the home button, I would get just the search part of the app. No cards were present, and none of the normal options about sample cards, etc., were there. The standard Google Now widget was there, but adding it to the home screen just showed one line of text: “Google Now is not available.” I ordered the device from the US and had it shipped to me in Iceland (through a third party of course – Google certainly doesn’t ship here), so this seemed like the likely culprit. Google Now has always worked fine on my Nexus 4, Nexus 10, and 2012 Nexus 7, so it’s unclear why that changed suddenly, but this is a very familiar problem to any Google user who doesn’t live on the actual corporate headquarters in Mountain View where all their services work. My attempts at the normal solutions (connect to a VPN, clear the app data, restart) didn’t work, and all of my web searches turned up the same solution – set the device language to US English and it should work. Alas, it didn’t. My device was already set to US English, and toggling back and forth to and from other languages did nothing.

Just on a side note, Google really needs to do something about their approach to dealing with the rest of the world. My advice to Google would be to take your fingers out of your ears and stop shouting “LALALACANTHEARYOULALA”, but I’m open to other suggestions as well.

Anyway, what finally worked was to go into the Settings -> Apps menu, select the Google Search app, and then hitting the “Uninstall Updates” button. This briefly warns you that you’re about to reset the app to its factory defaults, but as soon as I did that, it worked perfectly. The Play Store then showed that an update was available to the app, but it failed with a 927 error. I had to go clear the cache and app data for the Play Store app before the update would install. Installing the update didn’t break it again though, and it seems that everything is working OK now.

EuroClojure Wrapup

I’m just back from the first European Clojure conference in London, and I think the prevailing opinion was that it was a great success. I certainly enjoyed it, and I met a lot of great people doing cool things. In general, I think that’s how most conferences are judged – get interesting people to come and don’t do anything to screw it up, and you can have an awesome event.

The speakers were quite varied, but there were definitely several themes that emerged. Day one was quite heavy on the basic idea of “data” as an organizing principle for software design. This is a long-standing Clojure convention — eschew building new abstractions in favor of using the really good ones you already have. That is, the venerable “Employee” object should just be a Clojure map (a dictionary in python, hash table in some other languages).

This basic idea (and particularly the way it is reflected in the design of the language and standard libraries) is I think my favorite thing about Clojure, and a fair amount of the Big Ideas that are coming from the world of Clojure are simply extensions of this idea into new domains.

Probably the other big theme of the conference was Overtone, the open-source audio environment that has been a really popular presence at the last few Clojure events. There were three presentations on Overtone, and the lightning talk from Chris Ford was the highlight of the conference for me, which I suppose is saying something considering there were two Rich Hickey talks and a Stuart Halloway keynote.

Chris’ talk used Overtone to and Clojure to build up mathematical and functional definitions of canons (in particular he demos Bach’s Goldberg Variations), and shows how to not only construct the melodies and combine them to form various types of canons you can play using Overtone, but also demonstrates simple and elegant implementations to manipulate them in wonderful ways. Go right now to github and download the code from Chris’ talk. If you don’t know Clojure, use this as an excuse to learn it – it’s that good.

Aside from Chris’ talk, the notable successes for me were the following talks. Note that this list is personal. There were several perfectly good talks on things I simply didn’t care that much about, so don’t take this list as an exhaustive list of the “good talks”. These were just the ones that interested me the most for whatever reason.

Stefan Tilkov’s talk on Unlearning OOP

This was another talk around the “simple data” theme, and I thought he did a nice job of really grounding that idea into the language of a Java programmer who might just have found Clojure and is wondering how to structure programs in this strange new language.

Edmund Jackson’s introduction to core.logic

Overall, there was a lot of excitement around logic programming, and Edmund is a good speaker and gave a nice talk. One of the things that seems really well done about core.logic is how neatly it fits in as just another Clojure library. Part of this is the inherent of Lisp as a platform for these sorts of domain specific languages, but I also think the folks involved in core.logic simply did a very good job of designing a usable system. I’m really interested in seeing what benefits this has in terms of allowing fine-tuning how it operates at run-time.

On the down side, this overall excitement around logic programming was also one of the few things that popped up red flags for me. I don’t want to put words into anyone’s mouth, and it’s certainly possible that I missed some nuance somewhere, but my general impression of the community’s relationship with logic programming is something like naive optimism. The feeling sometimes strayed uncomfortably towards that of someone who has just discovered logic programming and is completely unaware of the history surrounding it. Anyone who’s written any serious Prolog code has struggled with the need to step inside the pretty formalism and start messing with the gears driving the search strategy. Prolog programs generally have cuts in them, and cuts turn your nice pretty declarative model into an imperative program written in the world’s least transparent language. There seemed to be zero awareness of this at all.

That said, much of the logic programming that was discussed here was in the form of things like Datalog, where conceivably, the problems won’t be quite so likely to arise. Basically, the problems with logic programming come up when you have deep search trees. Broad ones aren’t quite so much of a problem. If you have a list of a million facts (as in a simple database), you can answer queries by simply scanning the list in linear time if necessary. If you have the sort of complex relationships between your variables such that the value you assign to one may, many steps later, lead you to be unable to unify another, you have to backtrack, and this backtracking can go exponentially very quickly unless you do something to control it. One of the examples Edmund used was a course scheduling problem, and this is very nearly the “Hello world” of really nasty Prolog problems. It isn’t clear to me yet whether core.logic allows the type of search control that Prolog provides with its cuts, but either way, using core.logic for this sort of problem in the real world is likely going to be either impractical or impossible, not through any fault of core.logic itself – merely because it turns out that a pure declarative model is really difficult to scale in certain ways. Like I said though, I think having seamless access to Clojure under the hood gives the potential for really interesting variations – we should be able to tweak the declarative semantics to give better performance and scalability with a much better idea of how to control things. Overall, I think a move towards declarative programming where it makes sense is really a positive thing. I just think the level of optimism is probably a notch or two on the high side right now.

Stuart Halloway: Evident Code at Scale

Stuart is a great speaker, without a doubt. He gave a great talk on what he means by “evident” code, particularly focusing on Datalog to provide a declarative, logic-based programming model on certain types of tasks.

I’ve already said quite a lot about what I think here – declarative programming is awesome, right up until it isn’t. It remains to be seen whether Datalog’s more limited domain keeps it clear of the pitfalls that logic programmers have been dealing with for 30 or so years now, but I’m much more optimistic in that regard than in core.logic as a general-purpose computing model, at least in the short-term.

Rich Hickey on Datomic/Reducers

One of the speakers got stuck in Prague and couldn’t make it, and Rich agreed to step in and give a second talk on the recently announced Reducers framework in addition to his scheduled keynote on Datomic.

Much has been said about Datomic, and I have nothing much to add. Rich is, of course, an excellent presenter, and I learned quite a lot more about it that I had previously known, but it doesn’t fill a need I have. I think I was nearly unique among people I spoke with in that I tend to use Clojure as a better Lisp rather than a better Java. Most people were excited about things like Datomic and Pallet – practical tools for “the enterprise”, which is of course, perfectly valid. At the risk of heresy, I’d rather have had 40 more minutes of Chris Ford playing with the intersection of music and mathematics, but for the people who have much harder jobs than mine – the folks responsible for keeping the lights on and the trains running on time – the more practical things like Datomic, Pallet, and the various log and event handling related talks were probably really appreciated.

The reducers talk was much more interesting to me personally. I’m going to have spend a few minutes with the implementation to really understand them better – functions returning functions that create other functions is not exactly the kind of thing you can blow through in Powerpoint very well. However, the take-away is very nice, and my first impression is that it’s as elegantly designed and implemented as the rest of Clojure, which is pretty high praise indeed.

I’m going to toss one more downer in at this point though. During the talk, Rich made a comment to the effect of “and it’s just normal Clojure data structures – no parallel arrays of any of that object-oriented brain damage”. I’m paraphrasing, but that was the gist of it. The line got some chuckles and general approval, but the thing is that the “parallel arrays” people didn’t come to that decision because they’re idiots. They came to that decision because being elegant, pure, and N times slower wasn’t an option for them. Clojure is not currently a competitive platform for a lot of really compute-intensive work. Being pure has overhead; being lazy has overhead. If you’re writing a simulation that runs for two weeks on a cluster, going twice as slow means taking a month instead. Sometimes it’s worth it to be ugly. Sometimes that means things like “we can’t make normal arrays 10% slower just for thread-safety, so let’s just add a second array class that is thread-safe and let the user choose”. Yes, it’s ugly, but sometimes ugly and working beats the elegant solution that you can’t get off the whiteboard. It’s fine that Rich chooses not to take that route. It’s not quite so fine to be openly dismissive of those who do with no reference to the context in which they made those decisions. I don’t think this is news to people, but there is certainly a tendency to act like it is.

Mikel Brandmeyer on the history of lazy-seq

I think there was more here that I was unaware of than I thought going into it. I thought I had a pretty good grasp on lazyness in Clojure, but I did learn quite a lot from this talk.

Chistophe Grand: Not so Homoiconic

This was another of the talks that I think really resonated with the audience. Basically Christophe is working towards preserving more of the information that gets tossed by the reader, with the goal of enabling much richer classes of IDE-style source-code transformations. If you’re not a Lisp user, think of the reader as a kind of compiler. It takes in source code and spits out some other representation. Unlike a compiler, the representation is much closer to the original code than machine code or assembly language, but there are still many lossy transformations – comments and whitespace are discarded, certain types of variable references are rewritten into very unfriendly-looking forms, etc. If you treat Clojure code as data, you can read it using the Reader, but you lose all this valuable information. Christophe’s talk was on some ongoing work he’s doing towards trying to get around that without requiring changes to the language. The outcome would be some really great tools for writing better tools, and I think that prospect excited quite a few of the attendees.

Bruce Durling: Quick and Dirty Data Science with Incanter

How on earth did I forget Bruce’s talk when making the first version of these notes, given that his was probably the one I most anticipated as a “this can provide some practical help” sense? I use Clojure mostly for prototyping machine learning methods, and Incanter is one of the tools I lean on for this sort of analysis work, so I hoped I’d pick up some new tricks.  Bruce did a very good job I thought at the two major tasks he had in front of him: explaining what Incanter does to an audience with no special background in statistics and showing how to do some simple but useful tasks. 

Much of the material I already knew, but there were some bits that I hadn’t really used enough, and so I actually learned a fair amount of new tips as well.

Odds and ends…

A few unrelated points. First, serious thanks to Marco Abis for organizing the conference. There were a few minor issues (day one was incredibly hot), but overall, the conference was run beautifully. Everything from the selection of speakers down to the food provided was handled very well. I was also impressed by the tone of the speakers and attendees.

Others pointed out the severe gender imbalance – I don’t know the final breakdown of male/female attendees, but it was pretty stark. However, it’s hard to say any individual conference can do a great deal to change those realities. What a conference can very definitely do however is to send exactly the message that women aren’t welcome, and I happily didn’t notice any of that here. There was a question near the end that asked something about the culture of alcohol around meetups and dojos. There was definitely a lot of activity at the conference that took place after hours at the pub, and I know that a non-drinker would probably feel a bit put out or unwelcome. That’s a hard problem to solve. I will say that I don’t recall anyone crossing the line into any sort of obnoxious drunkenness, so I think at least a non-drinker could still participate in the community discussions. If a person really doesn’t want to subject themselves to an environment where there’s lots of alcohol around, it’s not a great solution.

I was slightly surprised by the number of people who were using Clojure professionally – that is, not very many of them. I don’t know that that’s either good or bad by itself – I think having things like Overtone is much more exciting that the typical sorts of things you’d see at JavaOne or some other conference where everyone is sent by their employers for training on the latest Java Enterprise Struts Foundation Builder Factory or whatever. The “hobbyist” vibe makes for a very friendly and diverse conference, and the people are probably more excited as well.

I also can’t resist making one more slightly negative point. There seems to be, at times at least, perhaps a bit too much hero worship in the community. Everyone wants to talk about how so and so “complects” this and that thing, or reference to how something is “simple” but not “easy”. I was talking with someone else who said it fairly well, that one gets the impression that if Rich stood up and said, “this homoiconic thing kind of sucks, I’ve decided — oh, and whitespace should be significant”, then the community would look very serious and studious and say, “You know, he’s right, I haven’t thought of it that way before”. By no means is this some endemic problem, and I think the core contributors certainly don’t fit this description. It does give a weird cargo-cult vibe at times though.

I want to end on a positive note. There were two full days of talks and lively conversations well into the evenings, and I’ve mentioned every negative point I could come up with. That leaves a lot of things that were very right. Thanks to all the organizers, speakers, and attendees for making EuroClojure a smashing success.

Syncing Google Contacts to BBDB – Introducing Charrington

I use Emacs as my usual mail client, currently with notmuch, but occasionally with Gnus as well. One of the really nice features to get working with any Emacs mail client is BBDB integration. BBDB, the “ubiquitous Big Brother DataBase”, is an address book for Emacs. It can do quite a few things, but I mostly only use it to autocomplete addresses when I’m sending mail.

Both my personal and work accounts are now hosted through Google Apps, and especially with an Android phone, Google Contacts is by far the most sensible place for my contacts to call their canonical home base. However, this introduces a problem – Emacs doesn’t want to play nicely with Google. There are tools, most notably the “Little Brother DataBase” (LBDB), which has connections to all sorts of data providers. However, (a) I never managed to get the UI for LBDB to be as nice and seamless as BBDB is, and (b) having to query a remote server to tab-complete an address introduces a really annoying delay.

There are a few tools out there that claim to write BBDB records from Google’s data, but I had very poor luck with them. They were fairly hard to get running, and typically left me with files that BBDB would choke on, perhaps due to character set issues (I have numerous Icelandic and other international colleagues with “interesting” characters in their names and addresses). Most of them seem to be quite old and unmaintained as well.

With that in mind, I wrote “Charrington”. The name is perhaps a little bit indulgent – Charrington was the member of the thought police in Orwell’s “1984” who turned Winston and Julia in to Big Brother. He kept Big Brother in the loop…get it? Huh? Like I said, it’s a stretch.

In any case, you can grab the code from Github and give it a spin. I’m sure there are plenty of bugs aside from the ones I already know about, so if you run into any problems, let me know.

Not Writing Like a Scientist

In light of the recent discussion around science writing, I decided to try a little experiment. I had an opportunity to submit a position paper to a workshop in my field recently, and it seemed like a perfect opportunity to try a more informal approach to writing. Position papers are always a little weird by their very nature, and the lack of hard data to present means you have a bit more flexibility in your prose, so I figured I’d give it a shot.

I got the reviews back today, and it was fairly mixed. The paper was accepted (barely), which is actually probably appropriate. I don’t think it was a really strong paper, and the scores seemed to me to be about exactly where I would have put them myself. So in that sense, writing informally didn’t seem to hurt me too much. However, there were several negative comments as well specifically singling out “informal” language, which was a little disappointing I guess.

Oh, and as a throwaway joke, I used the word “embiggened” in the paper, obviously a reference to the famous Simpsons neologism, which at least one reviewer complained about. The complaint was simply that it “isn’t a word, perhaps the author meant ‘enlarged’”, which probably indicates that the reviewer didn’t get the reference. No one else mentioned it at all, so it’s hard to say if it went unnoticed or was simply viewed as a perfectly cromulent word for a scientific paper.

I have to make some clean-ups for the camera-ready version, and there was enough push-back that I’ll probably rewrite some of the “worst” sections in a bit more standard scientific jargon.

Arch Linux on the Lenovo Thinkpad X220

First thoughts on the hardware

For the past several years, I’ve been using a Mac of one form or another as my everyday machine. For the most part, it’s been a pretty good experience. However, that experience has gotten worse, partly because Lion is just an abysmal OS upgrade, and partly because longstanding minor annoyances with Mac OS X have gradually become more and more grating. At some point, it occurred to me that what I really wanted was Linux again. I briefly considered just installing it on my Macbook Pro, but as I started looking at available PCs, I got really excited about the Lenovo x220. It’s a small, light laptop with high-end performance matched with very good battery life and the option of a second battery that snaps seamlessly onto the laptop. For things like conferences, this seemed like a perfect solution, and I pretty quickly convinced myself to buy one.

Overall, the laptop is really nice. I ordered it with the 6-cell battery and the additional “slice” battery. Together, they promise some 15 hours of battery life under Windows, according to Engadget. My last substantial experience with Linux on my everyday laptop was when power management was a noticeable issue, but I’ve so far been very pleased with how much time I’ve been able to squeeze out of a charge.

I purchased mine with the 2.8GHz Core i7 processor, 4 GB of memory (upgraded myself to 8GB), a 320 GB hard drive (upgraded myself to an Intel x25 160 GB SSD), the “premium” (IPS) display, the 6-cell battery, external “slice” battery, fingerprint reader, 720p webcam, the Intel 6205 wireless adapter, and bluetooth 3.0 adapter.

Without the slice battery, the laptop is very light, although not quite as thin as some other options. Particularly compared to the Macbook Air and competing Ultrabooks, it looks pretty chunky, but even compared to the Macbook Pro, it’s a bit thicker. However, it manages to mostly feel every bit as solid as my Macbook Pro, and with only half the weight. That “mostly” qualifier is necessary because of the rather odd fit of the 6-cell battery. The battery doesn’t fit flush with the laptop, instead extending a bit below the bottom plane of the case. However, it’s not the bulge that draws this complaint. Rather, it’s the fact that the battery feels loose. You can wiggle the battery around in its slot quite easily. It doesn’t seem to be anything that would cause any structural concern, but it definitely detracts a bit from the overall impression of fit and finish.

Update: It turns out that the latch holding the battery into my laptop was actually broken. I’m happy to report that despite my not being able to report the issue for several months (I ordered it over two months before I was back in the US to pick it up), Lenovo agreed to not only repair it for free, but also arrange to do so here in Iceland instead of having to send it away. The process of getting through their support channels to get to that point was frustrating. I’ll perhaps write up a bit more information on that when I have time. But for now, if you have significant looseness in the battery fit, double-check that it’s being locked in place securely and contact Lenovo if you think it’s excessive. Had I done so immediately, I could have saved myself some effort.

One area in which it seems no PC vendor has been able to compete with Apple is in trackpad quality, and while the x220 can’t either, I find the trackpad to be quite good overall. Out of the box, it wasn’t especially good – even in Windows 7 which came preinstalled. However, after installing Arch Linux and configuring the synaptics driver, the trackpad is very good. It doesn’t appear possible to configure the full range of gestures available on the Mac, but the most important ones are there (except for three-finger swipes for forward/backward, which are handled on the Lenovo through dedicated keys next to the arrow keys) and perform well.

The keyboard is, as one would expect from a Thinkpad, excellent. I strongly dislike the chiclet style keyboards Apple puts on all their systems now and which have since become de rigeur for most of the PCs I considered as well. Those forward/backward navigation keys are pretty easy to hit if you’re trying to reach for the arrow keys, and more than once, I’ve been typing something into a form on a browser, reached over to hit the left arrow to go back and edit a word or two previously, and accidentally hit the “back” button leaving the page and destroying my input. This is a problem that should mostly go away over time as I acclimate to the layout, but it’s something to be aware of.

It has a very nice assortment of ports available, although I’d much prefer a DVI port in place of the ancient VGA port. There is additionally an HDMI port, and with an adapter, this can provide a high-quality connection to a modern monitor, but it’s nonetheless silly to default to VGA output.

My other major complaint is with the screen resolution, but PCs in this class almost universally sport the same 1366×768 resolution. Sony’s VAIO Z series is available with a 13” screen and full 1080p resolution, but costs over $1000 more and still requires several compromises compared to the Thinkpad. The resolution of the display is low, but it’s not a dealbreaker. Aside from that, the display is very good. I went with the IPS version of the screen (a $50 upgrade from Lenovo), and the results are as one would expect. The viewing angles are very good, and the display is bright and crisp.

A bit more about the slice battery. It snaps in quite securely; ironically a much more solid fit than the standard 6-cell battery. Obviously, using it makes the laptop much thicker, but it’s still a light and portable machine. I don’t envision using it terribly often, but it’s a wonderful option to have when attending conferences or sequences of meetings that normally end up anchoring everyone it little circles around the nearest power outlet.

Overall, I’m very happy with the machine. If the resolution was a bit higher, even 1440×900, and the VGA port was ditched for DVI, it would be very nearly perfect. As it is, it’s very good, and those flaws are minor enough for me to live with. The battery life is amazingly good for a system this small, and with the optional slice battery, there’s really not another laptop on the market that compares with regard to runtime.

The Buying Experience

A final word about the laptop itself before I jump to getting Arch running on it. Lenovo really needs to do something about the experience of actually buying something from them. Like so many PC vendors, their website is generally a poor experience. It’s not quite a Dell-level train wreck, but it’s closer to it than it is to the experience of buying Apple. There are multiple different ways of finding the system, and the options are presented inconsistently depending on which you choose. In my case, I purchased using the Linux Foundation link, which saved me a fair amount of money. So thanks, Lenovo, for that at least. However, the configuration is divided into three screens. The first is the primarly laptop configuration options (processor, RAM, etc.). The second deals with warranty and add-on software options, and the third with other peripherals. In my case (but not via any of the other paths you can take to configure and buy an x220), the first page included an option to select between the 6-cell and 9-cell battery, and then a separate check-box to select whether to add on an external slice battery. Then the third page presented a list of several additional power options, including batteries. This list included another option to buy some sort of slice battery, but the description was slightly different, and it cost $60 more than the one listed on the first page. The “more information” links on each configuration section were mostly broken, popping up an empty white overlay. A few of the links worked – I could see more information about docking stations for instance, but for the batteries, nothing appeared. At other times, the links would populate, but with the wrong content. In short, the site itself was dreadful. On the plus side, the chat support was very quickly picked up, and the person on the other end was able to tell me that the two batteries were in fact the same, and that the one on page one was there and cheaper because it was part of a pre-packaged x220 configuration on offer. He seemed like he knew what was going on without having to go look up a canned answer in a knowledge base, and that’s very refreshing. But come on Lenovo, get the site in shape. We shouldn’t need to talk to someone to understand what you’re trying to sell us.

Arch Linux on the x220

I spent a few days using the Windows 7 install that came on the laptop just to get a feel for what to expect from the hardware, and then ditched the included mechanical drive in favor of a solid state drive on which I installed 64-bit Arch Linux. The drive bay on the x220 is too short to accept a normal 2.5” laptop hard drive, but the SSD I had, an Intel x25M 160 GB model, is actually a smaller drive with an included spacer. It’s easy to remove the spacer, but doing so leaves you without any screws to put back into the drive, as the included screws are long enough to account for the spacer. I had to visit a computer repair store kind enough to let me scrounge around a bin of screws, but after that, the drive slides in pretty well with the rubber sides from the included drive.

Installation of Arch (I went with the 64-bit version) was fairly uneventful. One thing you should be aware of if you’re buying an x220 is that you need to upgrade to one of the Intel wireless chips, otherwise you’ll end up dealing with a crappy Realtek driver, but the Intel 6205 chip in the one I bought worked without issue.

Disk configuration

I configured a small /boot partition, larger partitions for / and /usr/local, and the remainder devoted to /home, save for an 8 GB swap partition (I have 8 GB of RAM installed, and swap needs to be at least that large to support suspend-to-disk functionality). Because this is all on an SSD, I added the “discard” flag to the mount options in /etc/fstab to enable TRIM support.

Trackpad

The trackpad works OK out of the box, but you’ll want to configure the synaptics driver to get it to work well. In Arch, you need to install the xf86-input-synaptics-clickpad driver from AUR. This will create a file /etc/X11/xorg.conf.d/10-synaptics.conf. Read the synaptics man page for complete details, but I’ve included my configuration below.

Section "InputClass"
    Identifier "touchpad catchall"
    Driver "synaptics"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/event*"
    Option "TapButton1" "1"
    Option "TapButton2" "3"
    Option "TapButton3" "2"
    Option "ClickFinger1" "1"
    Option "ClickFinger2" "3"
    Option "ClickFinger3" "2"
    Option "VertEdgeScroll" "on"
    Option "VertTwoFingerScroll" "on"
    Option "HorizEdgeScroll" "on"
    Option "HorizTwoFingerScroll" "on"
    Option "LockedDrags" "on"
    Option "LockedDragTimeout" "500"
EndSection

This enables two and three finger taps and clicks, assigned to right and middle click respectively, two finger scrolling both horizontally and vertically, edge scrolling in both directions, and “drag locking”, which is the behavior that allows you to lift and replace your finger without interrupting a continuous drag event.

Wifi configuration

If you intend to run Linux, you should definitely upgrade to the Intel wireless chipset. I ordered mine with the 6205 adapter, which works well out of the box. However, getting up to speed on how Arch wants to support the alphabet soup of wireless standards was a bit of a hassle for me. I tried numerous options, all of which worked, but none of which was what I’d call seamless. Part of the problem is that the “friendly” methods tend to assume you’ll be using some Gnome applet to manage the connections, and I’m using Xmonad. I finally hit a sweet spot with Wicd. Configuration for my university’s WPA2-Enterprise network required a bit of trial and error (despite being a CS professor, I have next to no idea what the difference is between TKIP and CCMP is), but once I managed to get it connected, wicd seems to do a good job of connecting to my preferred networks and allowing me to intervene when needed.

Power managment

Power management was always one of the big issues for Linux on laptops. The slice battery on the x220 makes it less of a big deal, but I still want to be as conservative towards my battery as possible. Fortunately, I’ve managed to get the power drain down to very acceptable levels. I haven’t yet managed to get everything working the way I want yet, but it’s quite usable right now.

After installing the necessary packages (pm-utils, cpufrequtils, acpid, etc.), I had a few issues left to resolve. The default acpid handler script wasn’t able to correctly suspend to RAM when I closed the laptop lid. By default, the script tries to catch the actual ACPI events, but a bit of investigation showed that each time I closed and opened the lid, the event number was incremented. Instead, I modified the case in the handler script (at /etc/acpi/handler.sh) dealing with lid events to read as follows:

1
2
3
4
5
6
button/lid)
    if [[ `cat /proc/acpi/button/lid/LID/state | awk '{ print $2 }'` = "closed" ]]; then
        echo "lid closed" >/dev/tty5
        pm-suspend
    fi
    ;;

Now whenever any lid event occurs, it ignores the specific event and just reads the current lid state from the proc filesystem.

Hibernate, or suspend-to-disk, still isn’t reliably working. Currently, the issue seems to involve PulseAudio, but I’ve ran into multiple issues there, so I’m not entirely sure the current breakage isn’t related to something else I’ve done. Regardless, I haven’t had enough time to really dig into the problem just yet, but I’ll update things here when I resolve the problem.

Update: Hibernation is working fine as well, actually without much action at all on my part. I’ve done a couple of system updates since I last fooled with it, so perhaps it was just a matter of getting a new kernel. I’m currently on kernel 3.1.9-2-ARCH, and hibernation works fine out of the box. You will need to add the “resume” hook to your mkinitcpio.conf (as detailed here).

One other annoying issue I haven’t tracked down yet is that sometimes, after resuming from the suspend state, there’s a weird issue with the keyboard in X. If I have a terminal up, it seems to stop responding to keypresses intermittently. For example, I might type “ps -ef”, and nothing will happen after the “ps”. However, the key events are received – if I press enter in that example, ps does receive the “-ef” flags. Exiting and restarting X solves the problem when it occurs, so it’s an annoyance more than anything else, but I definitely want to spend a bit of time tracking down the problem.

CPU frequency scaling works well. I edited the file /etc/conf.d/cpufreq to select the ondemand governor by default, and added lines into the ACPI handler script as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
ac_adapter)
    case "$2" in
        AC|ACAD|ADP0)
            case "$4" in
                00000000)
                    echo -n $minspeed >$setspeed
                    for CPUNUM in {0,1,2,3}; do cpufreq-set -c $CPUNUM -g powersave; done
                ;;
                00000001)
                    echo -n $maxspeed >$setspeed
                    for CPUNUM in {0,1,2,3}; do cpufreq-set -c $CPUNUM -g performance; done
                ;;
            esac
            ;;
        *)  logger "ACPI action undefined: $2" ;;
    esac
    ;;

The additions are the two for loops that set the CPU governor for each CPU in the system. I also added the cpufreq daemon to /etc/rc.conf. I’m not sure if both of these steps are required or not.

Also, for reasons I don’t understand (and are almost certainly due to my absence from the Linux world for a while), I’m a little hazy on how certain events are being processed. In particular, some aspects of CPU frequency scaling and PCI power management aren’t happening automatically. For now, I’ve just been running the following script manually when I boot the machine on battery power or unplug the charger, but I need to figure out the appropriate way to get this to happen automatically. If necessary, I can hack a few scripts to force it, but I didn’t want to go that route until I spent a bit more time figuring out if there’s an elegant solution I just don’t know about yet.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

device_pm() {
        for CONTROL in /sys/bus/{pci,spi,i2c}/devices/*/power/control; do
                [ -w "$CONTROL" ] || continue
                echo $1 > "$CONTROL"
        done
}

case "$1" in
        true)
                echo "Device power management on"
                device_pm auto
                echo "Switching to powersave CPU governor"
                #echo -n $minspeed >$setspeed
                for CPUNUM in {0,1,2,3}; do cpufreq-set -c $CPUNUM -g powersave; done
                ;;
        false)
                echo "Device power management off"
                device_pm on
                echo "Switching to ondemand CPU governor"
                #echo -n $maxspeed >$setspeed
                for CPUNUM in {0,1,2,3}; do cpufreq-set -c $CPUNUM -g ondemand; done
                ;;
esac

exit 0

Edit: turns out the TLP daemon is apparently just misconfigured for my purposes. Changing RUNTIME_PM_ON_BAT=on to RUNTIME_PM_ON_BAT=auto in /etc/default/tlp solves the problem of PCI device power management not working automatically at boot.

Another remaining issue is that the Intel HD audio driver seems to generate a lot of wakeups according to powertop2. Note that you do need to install powertop2 from AUR instead of powertop 1.13 from the core repository, as only the newer version correctly supports reading information from sysfs.

Bluetooth can be stopped and restarted using rfkill (rfkill block bluetooth) and (rfkill unblock bluetooth). As I very rarely use bluetooth, I chose to simply disable it at boot; I’ll unblock it manually if I need to use it. Because it’s sometimes handy to have a convenient place to do this sort of thing, I created a new script in /etc/conf.d named local that I start at boot time. Currently all it does is run the rfkill command to turn bluetooth off, but I can add more things later if needed.

I also modified my xmobarrc to ensure than nothing happened at greater than about five second intervals. On my desktop, for instance, I have an entry showing the time in hh:mm:ss format, updated every second, along with CPU and memory monitors. Dropping the frequency of the system monitors to five seconds and dropping the seconds from the date so it could be updated once per minute saves a noticeable amount of power from the reduced wakeups.

With all this in place, I’m getting very good battery life. With the screen dimmed to maybe 40% brightness, I’m seeing around 7:00 to 7:30 of normal usage on the 6-cell battery. I haven’t done any real testing, but that seems to be a reasonable estimate based on the discharge rate I’m seeing. With the slice battery connect, that number jumps to maybe 15 hours. Powertop doesn’t work completely with sysfs, but Powertop2 is available in prerelease form in AUR, and it shows an average of about 7.5W when the system is idle, although often I see higher use due to my not having managed to get a completely automated solution for setting all the needed options.

Other stuff

The audio and integrated webcam worked fine out of the box. As is typical with Arch, you need to add your user to the appropriate groups for device permissions, but nothing else was needed.

Bluetooth presumably works fine. It detects the controller and turns everything on, but I almost never use bluetooth, and I haven’t tested it to see if it works yet. I actually disable it in /etc/rc.local to save power.

The fingerprint reader doesn’t seem to work, or at least that seems to be what I see online. I haven’t tried to configure it at all. Running fprintd-enroll and swiping across the reader, I do see it detect my finger, so it’s possible that it works just fine if I knew how to configure it, but it’s also possible that there’s no driver for the protocol it speaks, and thus no way to make use of the data. I don’t know.

I think that covers the major points. I’ll update this as I continue to figure things out, particularly the remaining power management issues. For now though, it works plenty well enough for my everyday usage, and if you’re in the market for a small, powerful laptop with absolutely unmatched battery life, I recommend it pretty highly.

Esjan, Part Tvö

It was such a nice day today, I decided to go back up Esjan. This time, I remembered to turn on my GPS tracker to record some information about the path.

According to Google Earth’s interpretation of my GPS log, the total trail was 4.48 miles (7.21 km), 2.5 miles of which were ascending and the remaining two miles descending (I took the longer more meandering trail up and the more direct one down). It took three hours and 22 minutes in total, almost two hours of which were ascending. The elevation gain was 2627 feet (800 meters) from the parking lot to the summit. The average grade on the ascent was 19.9%, with a maximum of 41.5%. Descending the steeper trail, the average grade was -23.1%, and -41.8% at the steepest point.