McCain

8 May 2007

Last week US Presidential candidate John McCain appeared at Google. It was quite an interesting talk and being a bleeding-heart-European-liberal I was actually pleasantly surprised by some of his answers. What didn’t sit quite right with me was the religious rhetoric and his seemingly black-and-white distinction of good vs. evil. The race is already getting interesting, shame I don’t get a vote. Anyway, checkout the video on YouTube, I was sitting just behind the left mic.

9 to 5

1 May 2007

I work in a crazy place. Today every one in the Mountain View office got given an Earthquake Preparedness Kit, complete with water and food supplies, tent, gloves, first-aid kit, ducttape, solar powered torch (yes, really), and a bunch of other stuff that would help us survive in an earthquake.

Garbage Collection in IE6

7 March 2007

I’m not an avid blogger, and when I do post it’s rarely tech related. But recently I have had cause to do some investigation into the effects of Internet Explorer’s garbage collection routines on performance, and I thought it would be useful to summarize some findings.

Eric Lippert posted about the internals of IE’s garbage collector back in September 2003, though he skimmed over the important bits, which were later noted in the comments. The crux of the problem is that IE’s script engine uses allocations to determine when to run the GC; that is after 256 variable allocations, 4096 array slot allocations, or 64kb of strings have been allocated. Not only are allocations a bad indicator of garbage, but these limits are such that any decent sized application is going to make the GC run pretty regularly.

To compound this problem, the running time of the garbage collection routine is dependent on the size of the working set (O(N^2) as described in Lippert?s article, though the results below show a linear relationship). So as your application gets bigger the garbage collection runs slower.

Back in the day this didn?t really matter, but as web applications are getting more complex there is the potential to hit a performance wall. More code being executed means the garbage collector will be run more frequently; and because the applications contain more state on the client; and have larger code bases, the object graph that the garbage collector has to traverse gets bigger.

To demonstrate the effects of this on performance I?ve used a simple benchmarking function which creates 5000 object literals with random properties, and then sorts them. The function is then run on a simple HTML page, pre-populated with a further O-objects, each with P-properties, which will always remain in scope.

The following results show the mean execution time of the create-and-sort test as O increases for constant P=50 on Firefox 2.0 (red) and IE6 (blue) on the same computer.

http://www.endoflow.com/gcbench/gc_graph.png

Try the test for yourself.

Now, the test environment is quite contrived in that it creates the literals as homogeneous global variables in a simple scope, but the effects are the same if you create objects dynamically, with scope chains exposed via event handlers and closures.

I doubt there are many web applications that are big enough to be seriously impacted by these problems, though it is worth bearing in mind, since performance is proven to be strongly linked to adoption of web apps.

Microsoft issued a hot fix that allows you to increase the allocations, this gives a significant performance boost, but you don?t want to force all your users to patch IE so this isn’t a viable solution. IE7 seems to have solved this problem by having dynamic allocation thresholds that scale to the size of your application, but rollout of IE7, particularly to corporate users, is likely to be slow for the rest of 2007. The other options can be painful and basically involve optimizing your application by reducing code size and finding the balancing point between improved performance from keeping state local and keeping your working set to a manageable size. Always explicitly dispose objects when they are no longer needed by removing event handlers and dereferencing properties.

References:

Eric Lippert’s 2003 post: “How Do The Script Garbage Collectors Work”
http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx

Micrsoft Support Article: “You may experience slow performance when you view a web page that uses Jscript in Internet Explorer 6″
http://support.microsoft.com/kb/919237

Bike2Work

18 May 2006

http://www.dribbleglass.com/subpages/strange/bike_path.jpg

It is bike-to-work day today, so I decided to join a group of cyclists riding down to Google from San Francisco.

The ride is 40+ miles and takes you down the edge of the bay, past the airports and industrial estates to Palo Alto and then over to Mountain View. Everyone else was on road bikes, so it was tough for me to keep up. Pretty much the whole way I felt like I was flat out in top gear, and if they’d gone any faster I just wouldn’t have been able to maintain the speed.

But I made it and the only things that are really hurting are my arse (I need cycling shorts) and my back (to make it even harder for myself I had a back pack).

Right, off to get a much needed shower.

6-months

1 May 2006

I’ve been working in the states for 6-months now. Which is crazy. This is the longest I’ve been outside the UK in one go. Things are still good, though it seems I suffer from hay fever in California too :(

Things I’ve done in the last few weeks:

– Visited JJ in Whistler, British Columbia, for 4 days snowboarding

– Seen Blackalicious play

– Seen Yeah Yeah Yeahs at The Warfield in San Francisco

– Jumped out of a plane for the third time (Category C1 sky dive)

– Read The United States of Europe

– Worked a lot

I helped Gmail learn to talk

6 February 2006

So I started work at Google just over three months ago and today the project I have been working on is launching: chat in Gmail!

I met my team for the first time on Halloween; it was a surreal day, with one colleague painted red and dressed as the devil, and another two peering in through a TV screen from a remote office. When I joined, the project had already been going for quite a while so I can take only a little credit for what is a truly kick-ass feature. My input has been limited to a few small features, dealing with a myriad of browser issues, and code refactoring.

Over the next couple of weeks you should see the features turned on in your own Gmail accounts. But for the time being here’s some more reports about what we’ve been doing.

There is also a lot more cool stuff on the way :)