Friday, April 27, 2007

Ubuntu Names

Oddly enough, Ubuntu has a web page about the names. Apparently, it just didn't occur to them to go in alphabetical order until after breezy. But why did they skip C?

I think Adjective Animal would be a great name for their 27th release.

Azureus

What's the story with this piece of crap? Azureus seems to be every right-thinking Linux geek's favorite BitTorrent client, but I have never once had it succesfully download anything. It hangs and/or crashes pretty much immediately. This has been the case on multiple computers and four different versions of Ubuntu. Is it me? Is it SafePeer?

[UPDATE] There was a widespread, virulent bug in Azureus. I've been able to work around it, though I'm not quite sure how. It really is a great BitTorrent client...

Feisty Fawn

I upgraded my laptop from Ubuntu edgy to feisty last night and I'm please to report (after a rather unpleasant experience upgrading from dapper to edgy, documented here, here, and here) that the whole thing went off without a hitch. The upgrade process asked a lot of annoying questions about whether or not it should clobber various config files, but I just said "Yes" to all of them and have seen no ill effects. It even gracefully downgraded my nVidia driver to the latest version in the Ubuntu repository and Suspend still works. Who knew that was possible?

Are there any great benefits to upgrading? Um... not that I can tell. The version of Liferea is more recent and there's a search button in the Panel. These are hardly blockbuster features. The main benefit to me is that "are you running feisty?" will not be the first and last response to every question I post to the support forums. (This will be replaced with "are you running gutsy?" within a month.*)

* Speaking of which: I am really fond of the names Breezy Badger, Dapper Drake*, Edgy Eft, and Feisty Fawn. But, Gutsy Gibbon? Yuck.

** Does anyone know the story behind the naming scheme? I.e., how Ubuntu went from Warty Warthog and Hoary Hedgehog to the current Sue Grafton-esque release-naming convention? And why they skipped A and C?

Wednesday, April 25, 2007

Profiling OCaml... Revealed!

Profiling OCaml code is kind of a hassle. The simplest thing is to use ocamlopt with the -p option, then apply gprof as usual. The problem here is that the debugging symbols produced by the OCaml compiler are of limited usefulness. For example, fun expressions show up with names like camlModule__fun_2397 (where 2397 has nothing to do with anything) and, I think, continuation-passing transformations in the back-end can lead to confusing call graph relationships where functions that shouldn't be compute-intensive at all end up looking like hot spots.

Now, you may think this is all due to the conversion to C calling conventions and the corresponding loss of high-level information at execution time and therefore the solution would be to profile bytecode. So you might try to compile with ocamlcp, the profiling bytecode compiler. Along the way, you'll figure out that ocamlcp doesn't allow the -pp option... No problem—if your project is sufficiently small or your Makefiles are sufficiently modular—you can just run the preprocessor separately and pass the preprocessed files in to ocamlcp (just add pr_o.cmo to your camlp4 command, to dump the pretty-printed version of your code instead of the AST object).*

Then you'll discover** that what ocamlprof gives you is not a data dump like the output of gprof, but a source file annotated with execution counts for each expression. And you'll realize that this is in some ways useless—you really need time information to do effective profiling. For example, the polymorphic equality function (that's, um, = for you non-functional programming types) is going to have a massive execution count in just about any program you write; that doesn't mean you need to rip it out and hot-rod it.***

Now, here's where I made an interesting discovery: the byte- and native-code compilers seemingly dismantle the source code in similar or identical ways. You can take the execution count for an anonymous fun expression from the gprof output and match it up with the execution count on the source expression from ocamlprof.

Here's an example. gprof tells me the following:


Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
28.57 0.08 0.08 1064344 0.00 0.00 compare_val
17.86 0.13 0.05 82370 0.00 0.00 camlAtp__itlist_116
10.71 0.16 0.03 2284937 0.00 0.00 caml_apply2
7.14 0.18 0.02 1657397 0.00 0.00 camlMlss__fun_1052

The far left column tells you what percentage of the execution time was spent in the function named on the far right. The column in the middle tells you how many time the function was called. The first three rows name built-in and generic functions—it's not surprising that the program spends a lot of time comparing things, iterating over lists, and invoking functions. The fourth row names camlMlss__fun_1052, an anonymous function, which accounts for 7.14% of running time. Where is this function?

gprof outputs the following call graph information:

-----------------------------------------------
28217 camlMlss__fun_1046 [167]
1629180 camlAtp__itlist_116 [11]
[16] 12.0 0.02 0.01 1657397 camlMlss__fun_1052 [16]

In other words, camlMlss__fun_1052 is called from some other anonymous function and from a generic list iterator. That's not very helpful.

But if we go over to the output of ocamlprof, we find this:

let saturation_rule2 f terms theta =
(* 546 *) itlist
(fun fm r ->
(* 28217 *) try
let g = f fm in
itlist
(fun fm r ->
(* 1657397 *) try g fm @ r with
Match_failure _ -> r)
theta r
with
Match_failure _ -> r)
theta []

The numbers in comments are invocation counts. The innermost fun expression is called 1,657,397 times. Does that number look familiar? Notice also that the next enclosing fun expression is called 28,217 times, which is exactly the number of calls attributed to the anonymous parent of camlMlss__fun_1052 in the gprof call graph data. We have found our hot (er, warm-ish) spot!

I'm not sure how reliably this works in general. The cited results were obtained by running ocamlcp with the -g and -p f arguments. It might be fun, if one could find some spare time, to write a utility that used the ocamlcp output to annotate the gprof data with (probable) line numbers.

* Note that the pre-processed file must have a .ml extension or the OCaml compiler will refuse to have anything to do with it. Note also that foo-pp.ml is not an option, because the filename must be a valid module identifer when the first letter is capitalized (i.e., your canonical [A-Za-z][A-Za-z0-9_]* identifier).****

** We assume throughout that you are a foolish person like me: that you only read the documentation for such things far enough to get them running and are consequently constantly surprised by what programs actually do, since you assume that they ought to do what they seem to be intended to do.

*** Although you may run into trouble if you use polymorphic equality on big, complicated (or, gasp, cyclic) data structures.

**** Note to self: is there a reason the OCaml convention is to use lowercase file names when the module system implicitly capitalizes it and for use as a module identifier and a capitalized file name is also accepted by the compiler? I.e., why don't we match the case of file names and implicit module declarations? Oh me, oh my, why, why, why?

Sunday, April 22, 2007

The Universe (Sort Of) Hates Me...

Well... Let's call it a patent dislike.

I specifically left the house this afternoon to get my wedding band resized—an errand I've been meaning to run for about six months now*—only to find that every jewelry store in Park Slope is closed on Sunday. What's the deal?

But you know who is open on Sunday? The 5th Avenue empanada lady. You know how much an empanada costs? A dollar twenty-five. And you know what they are? Delicious.

Eat that, universe,

* The band has seemed a little too big since I got back from India, probably because of the 10 pounds I lost there (which have oddly stayed off, even after I returned to my customary diet of cow, pig, and Ben & Jerry's ice cream). The band has fallen off my finger twice: once on the street in Sunset Park and once on the beach in California. I haven't determined the precise combination of external/internal/body temperature and humidity/sweatiness that puts it in the danger zone, but I find that I self-consciously walk around with my hand curled in a fist, lest the band leap from my finger and into a sewer and/or the jaws of a whale.

[UPDATE] Upper East Side jewellers have a better work ethic, but $80 to shrink a platinum band a half size? Is that really how much it costs?

Friday, April 20, 2007

That word. I do not think it means what you think it means.

Today's NY Times article about Harry Reid contains the single most idiotic piece of argumentation I've ever heard from a Republican (and that's saying something):


Representative Peter Hoekstra, a Michigan Republican, said: “If Harry Reid believes that this war is lost, where is his plan to win this war?”

Blogging from Jury Duty!

Free public Wi-Fi in the courthouse!

Totally, Man. They Didn't Even Have MySpace Back Then.

Quote of the Day: "Twentieth century? Why, I could pick a century out of a hat, blindfolded, and come up with a better one." -Oliver Larrabee, Sabrina (1954) (not the compromised second draft)

Thursday, April 19, 2007

Straw Men in Jars

Shorter David Brooks: We are not brains!

(Sorry about that pay wall.)

Tuesday, April 17, 2007

Women in Computer Science

It's always been a problem and, apparently, it's getting worse. (Though, in fairness to the discipline, enrollments in CS are down dramatically across the board and seem to be down proportionally somewhat less for women, especially at the doctoral level (which I inferred from squinting at this graph)).

What can I say, ladies? It's not all programming, but programming is an important part of it. If you don't like staring at a screen all day... well, then you're probably not cut out for 21st century office work. You can only read so many papers (and even papers don't have to be on paper if you don't insist on it).

CS could do a better job of selling itself as a mathematical rather than an engineering discipline—it's really a little of both, and you can choose the proportion that works best for you depending on your interests (for instance, my work is probably 60/40 math/engineering; most of my peers/colleagues are probably more math-centric). Neither math nor engineering are at gender parity, but math is better than CS and engineering is worse.

On the glass-half-empty side, CS is—and is likely to remain—a male-dominated discipline. And the men you'll find, while not necessarily the classic pocket-protectored nerd (I've never once seen a pocket protector on a computer scientist; I think that's a slide-rule-era stereotype), tend to be socially awkward in one way or another. (But academia, in general, seems to attract introverts.)

On the glass-half-full side, universities, research labs, and funding agencies are absolutely desperate to encourage women to pursue computer science as a career. If you are a math- or technologically-inclined female (especially if you are an American female: China and India produce proportionally more female computer scientists (I think, no data to back that up)), you'll have a comparative advantage in CS vs. math and the physical sciences. Which is not to say you'll get a free ride. But there will definitely be a thumb on the scale in your favor.*

* Must... suppress... white male... resentment... So hard... being white... and male...

Monday, April 16, 2007

Unzip into a subdirectory!

Most folks know this. If you are one of those folks, just move along. I'll wait...

Now. When you make a TAR or ZIP file, make it so the files will un-tar/zip into a subdirectory, damn it! Do you really think I want your files spread all over my /usr/local tree?

This is especially common amongst people who make ZIP files, so I'm usually on my guard for it. But tarballers: come on! Get with it! It's easy: "cd ..; tar cvf foo.tar DIR"

Some Thoughts on Taxes

First, I'd like to observe—uniquely, I think—that people like me ought to pay less.

Second, it hardly needs to be said that it would be both good politics and good policy to simplify the tax code and payment system. You see, if paying taxes wasn't complicated, time consuming, and painful, people wouldn't mind paying them so much. John Edwards is apparently hip to this, as are the wing-nuts. (Via Becks via Neil the Ethical Werewolf)

Finally, if you are a giant corporation with an internship program, a nice benefit you could provide—nicer even than a ping-pong table or free snacks—would be free tax advice. Along these lines, you could also make a little effort not to put your interns in an annoying, complicated tax position.

P.S. Oh, yeah, I meant to say: it's your patriotic duty, blah blah blah.

Saturday, April 14, 2007

Oh, Brave New World That Has Such Feces In It

I've been meaning to blog the LitterMaid self-cleaning litter box for months now. Every time I come into contact with the damn thing it makes me want to call my congresswoman (hi, Nydia!).

If you're not familiar with the product, it's a litter box with a sensor and a motorized rake. A few minutes after a cat jumps in the box, the rake makes a pass over the litter and scoops whatever is clumped there into a little plastic bucket. Sounds pretty great, right? Wrong.

People on the Internet are not happy with this product. A lot of complaints are centered on the apparent fact that the motor breaks down quickly and often. But even with a fully operational motor, this is a deeply flawed product.


  1. If you fill the box up to the line marked "Full"—or even just somewhat near it, say, anywhere above the line marked "Add Litter"—or, actually, to tell the truth, even if the box is not the least bit full but the litter is somehow unevenly distributed into unfortunately placed dunes—the rake will actually get stuck, going back and forth and back and forth all day or night—oh, and did I mention that it's really fucking loud—until you turn it off and remove some (or a lot of) litter and smooth it out and pray.


  2. The rake teeth are about a half inch apart and don't reach down to the bottom of the box. Tiny poops escape unharmed. A layer of fine urine-soaked dust accumulates. Stench ensues. The thing weights 20 or 30 pounds, so dragging it into the bathroom or backyard to scrub it out is a hassle.


  3. With a regular litter box, if you want to ignore it for a week or more, you just have to play chicken with your cat's inclination to go start pooping and/or peeing somewhere else. Usually, at least in our case, the box will become just completely unacceptably stank long before the cats give up on it.

    With a LitterMaid self-cleaning litter box, if you ignore it for more than a few days, it starts scooping poop and urine-saturated litter onto the floor. Thus, the self-cleaning litter box, far from relieving you of the stresses of litter box management, actually makes careful attention to the state of the litter box more important.


  4. Somehow, because of the way the dirty-litter bucket is wedged into a little gap on the side of the box, you are actually more likely to come into contact with cat shit in the process of changing the litter than with an old-fashioned litter box and scoop.



So, to summarize, here is the litter box of the future: it's loud, it's stinky, it scoops shit onto your floor, and then makes you touch it. And then it breaks! It gets my highest recommendation.

Kids, Don't Be Like Me

You probably think there's just no possible way your computer's BIOS could fail to recognize your new ginormous EIDE hard disk—that problem just sounds so DOS-era, doesn't it?—but, yes, this can happen to you. My PowerMac G4 thinks my new 400GB drive is... 128GB. And the best part is: no returns! Who's the tech expert in this house? I am!

Thursday, April 12, 2007

Seriously?

The security guard in my building, who let's me walk by with a nod 9 times out of 10, chooses today, when I've got a bag and an umbrella and a hot cup of coffee, to ask for ID? Really?

I never know where I stand with these people. Am I supposed to do chit chat? I hate chit chat.

Oh, Ubuntu...

It just wouldn't be a system update if it didn't break Suspend.

If, for whatever reason, you have been moved to install the latest version of the Nvidia drivers—eschewing the always classy, always out of date nvidia-glx package—you must must must re-install after a kernel upgrade. The reason being that the driver compiles a custom kernel interface that is, in all likelihood, now broken.

Bonus tip: How do you shut down the server so that you can install the driver?

sudo /etc/init.d/gdm stop
(Or,
sudo /etc/init.d/kdm stop
for you Kubuntu people. (What's wrong with you?)) (Hat tip: TheOS)

Wednesday, April 11, 2007

Television's "Marquee Moon"

Not good treadmill music.

Saturday, April 07, 2007

एक्ष्केल्लेन्त् वर्क, टोबी

Mr. Kellner (who else?) wins the prize, which is no prize. Bonus points if you know where it came from. BTW, my browser doesn't even render this script properly. Something to do with the right-to-left text.

Friday, April 06, 2007

आ गूढ़ ग्लास इन थे बिशोप'एस होस्टल

Blogger snuck a Hindi transliteration feature into the post composer. Why? I don't know. Does it work? Beats me. What does it say above? Does it make any sense?

Thursday, April 05, 2007

Moving to a new Gmail account

Interestingly, it can be done without losing your email, although it is not officially supported. Here's how it's done (with a hat tip to these guys over here):


  1. In your old account, go to "Settings -> Forwarding and POP" and select "Enable POP for all mail".

  2. In your new account, go to "Settings -> Accounts" and select "Add another account"

  3. Enter your old email address and click "Next."

  4. Enter the username and password for your old account. From the "POP Server" drop-down list choose "Other..." and type in "pop.googlemail.com".* Unselect "Leave a copy of retrieved message on the server."** You may also want to tag or archive the retrieved messages, but you can change these settings later.

  5. Click "Add Account." If something goes wrong, fix it.

  6. Now wait. The emails will come slowly and out of order, but they will come. They'll even have all the right timestamps and such. It took about 8 hours for approximately 800 messages to be loaded from my old Inbox. (Presumably, Google throttles the message transfer so that you don't interfere with everybody else's everyday Gmailing.)

  7. When all of the emails have transferred, you can go back, turn off POP, and enable regular forwarding. This will be much faster, in general.


Transferring your contacts is easy. The Export/Import links are in the upper right corner of the Contacts page. There doesn't seem to be any way to get somebody into your Quick Contacts box without sending them an email.

Note: Changing your Gmail account will screw up all your other Google Account stuff. Like your Blogger account. D'oh. [UPDATE: No really, this is probably the worst "feature" of Google Accounts. If I log into Blogger, I log out of Gmail and vice versa. I can probably somehow get around this by inviting the new me to join this blog...] [UPDATE 2: As you may notice in the Contributers bar to the right, there are now two of me contributing to this iblog. This is annoying.] [UPDATE 3: This was a known bug with "New Blogger" that has since been fixed.]

* This is part of the trick. The pre-fab list of gmail.com servers won't let you suck in all of your mail, but this undocumented googlemail.com server will.

** This sounds frightening, so some clarification: Gmail won't let you leave this selected; they've got the POP server set up to complain if you do. However—and this is weird—your mail won't actually be deleted from your old account. This setting doesn't mean what it says, somehow.