Procrastiblog

April 27, 2007

Ubuntu Names

Filed under: Linux, Tech, Waste of Time — Chris @ 4:06 pm

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.

Advertisements

Azureus

Filed under: Linux, Tech — Chris @ 3:53 pm

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

Filed under: Linux, Tech — Chris @ 3:28 pm

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?

April 25, 2007

Profiling OCaml… Revealed!

Filed under: OCaml, Tech — Chris @ 5:00 pm

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?

April 22, 2007

The Universe (Sort Of) Hates Me…

Filed under: India, Not Tech — Chris @ 6:42 pm

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?

April 20, 2007

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

Filed under: Not Tech, Politics — Chris @ 11:34 pm

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!

Filed under: Not Tech — Chris @ 12:44 pm

Free public Wi-Fi in the courthouse!

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

Filed under: Not Tech, Waste of Time — Chris @ 4:19 am

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)

April 19, 2007

Straw Men in Jars

Filed under: Not Tech, Politics — Chris @ 1:28 pm

Shorter David Brooks: We are not brains!

(Sorry about that pay wall.)

April 17, 2007

Women in Computer Science

Filed under: Not Tech — Chris @ 3:23 pm

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…

Older Posts »

Blog at WordPress.com.