Archive forAugust, 2005

Exploring the galaxy

Just a few days after the announcement that our galaxy is a different shape than previously thought, I’ll be up in Seattle this weekend helping Galactic Consortium Press celebrate the 42nd printing of The Mooncurser’s Handbook. I’ll be playing with Erik, Nick, Marc, Deb, and Rick. I’m sure we won’t win, but it should be a lot of fun.

Comments (4)

Power gardening

My townhouse has a small backyard. I ignored it for the first year I lived here, which meant that everything the previous residents had there — a few random plants and a lot of grass — either grew or died as it felt like. By early July of this year, I had my own little jungle out there.

That’s when I decided I’d like to be able to walk from one back door to the other and therefore things had to change. And if I was going to tear up some of it, why not tear up the whole thing, put in some of my own plants, and put a little bit of effort into not killing them? Actually having them grow well would be a bonus.

A couple weeks ago, Adrienne was up here and picked out two king bougainvilleas for me. I’d cleared out enough space to plant one of them, so we put that one in and I figured I’d dig up the plant in the back corner to create the hole for the other one.

One thing led to another and I didn’t get around to attacking that other plant till this past Friday night. After a few hours of digging, I finally got it out on Sunday afternoon…but not before discovering that right below it was some sort of large object. Additional digging ensued and I realized it was a log.

Well, I couldn’t very well plant my bougainvillea directly over a log, could I? Maybe I could…I wouldn’t know these things, considering that my entire knowledge of gardening theory is “water + sun + soil = green stuff and sometimes pretty stuff in other colors”. But I know I’d feel bad for the poor bougainvillea, valiantly struggling to survive with the Underground Log of Pure Evil in the way.

I kept digging. Finally, tonight, after many hours of digging during which I often felt like I was on an archeology expedition trying to unearth treasures, I got it out. The whole thing was lying sideways over a foot deep in the ground, about six inches in diameter, and more than two and a half feet long. (And hollow, which seems weird. Do buried logs break down from the inside?) That might not sound big, but when all you have for gardening tools are a spade and a shovel and the only water that’s gone into the soil in the past few months is what you put in there to soften it up enough to take out the single plant you thought was there, well, it feels big.

Anyway, to the next person who tells me that I don’t exercise enough, I’m going to tell them I do power gardening on a regular basis. Man, am I sore. There’d better not be any other logs in the rest of the backyard.

Comments (4)

class-dump

I saw a thread on Usenet tonight which mentioned that the class-dump utility didn’t work with universal binaries, so I took a few minutes and patched it up. It only displays data for the host architecture side of the binary, but that’s still better than aborting.

To get the changes, download the source code for the main project, then replace CDMachOFile.m with this version and build.

Update: Steve Nygard did a much better job than I did and not only added universal binary support to class-dump, but also added a --arch flag so you can display any architecture you like. class-dump 3.1 is now available.

Comments off

BBEdit 8.2.3 is universal

BBEdit 8.2.3 was released today as a universal binary, so I can run it natively at work. Very cool.

Comments (1)

The wild world of Web servers

Buzz points out that not only did Andrew post something to his weblog for the first time in, well, a long time, but it’s a fascinating post, too. If you’ve ever wondered what the secret messages hidden in the Web are, well, he’s found them for you.

One of the million or so links in that post leads to a page I wish I’d known about long ago: Andrew’s list of April Fool’s RFCs. Never again will I have to spend minutes searching for the right way to send Internet traffic via pigeons or what to do with my collection of an infinite number of monkeys.

Comments off

Objective-C messaging

Peter has some interesting thoughts about objc_msgSend. His post is worth reading if you’re curious about some complicated ways to improve performance, but there’s one important thing missing: This shouldn’t be necessary for nearly all developers.

Premature optimization is almost always a bad idea. I’m a bit concerned that folks will read Peter’s post and think, “objc_msgSend is slow! Hey, I use Objective-C! I can make my code a lot faster by tweaking my compiler!” Bad idea. The reason why objc_msgSend spends a third of its time in the dyld stub (at least for Peter’s test) is that objc_msgSend is really fast. Lots of people have spent lots of time over the years making it as fast as it can possibly be. (Which isn’t to say that it can’t be faster…feel free to grab the code and see if you can improve it without breaking binary compatibility.)

In other words, if your application has performance problems in certain areas, chances are it isn’t due to objc_msgSend. Measure your application’s performance with Shark, and in the unlikely event that a specific algorithm is spending too much time in objc_msgSend, there are two simple solutions that can help:

  • Rewrite your algorithm (not your whole application) to not use Objective-C messaging. If you’re using Objective-C, you’re using a dynamic language. The dynamism is great, and Apple’s implementation is phenomenally fast for a dynamic language, but it just won’t be as fast as C.
  • In a local variable, grab a function pointer to objc_msgSend, grab your selector in another variable, and call the object and selector through your function pointer. This is similar to what Peter described, but it’s much more common, doesn’t involve changing the compiler, and doesn’t have the overhead of using a global variable.

Again, though, the need for this is exceedingly rare. If your application already performs fine for your users, you’re much better off spending your time making it a better application than tweaking it so the frobnaz can blindle in six microseconds instead of nine microseconds. Making your frobnaz that much faster may sound cool, but really it’s a waste of your time.

Comments (1)