Hammerhead: moving performance testing upstream

September 30, 2008 10:07 pm | 54 Comments

Today at The Ajax Experience, I released Hammerhead, a Firebug extension for measuring page load times.

Improving performance starts with metrics. How long does it take for the page to load? Seems like a simple question to answer, but gathering accurate measurements can be a challenge. In my experience, performance metrics exist at four stages along the development process.

  • real user data – I love real user metrics. JavaScript frameworks like Jiffy measure page load times from real traffic. When your site is used by a large, diverse audience, data from real page views is ground-truth.
  • bucket testing – When you’re getting ready to push a new release, if you’re lucky you can do bucket testing to gather performance metrics. You release the new code to a subset of users while maintaining another set of users on the old code (the “control”). If you sample your user population correctly and gather enough data, comparing the before and after timing information gives you a preview of the latency impact of your next release.
  • synthetic or simulated testing – In some situations, it’s not possible to gather real user data. You might not have the infrastructure to do bucket testing and real user instrumentation. Your new build isn’t ready for release, but you still want to gauge where you are with regard to performance. Or perhaps you’re measuring your competitors’ performance. In these situations, the typical solution is to do scripted testing on some machine in your computer lab, or perhaps through a service like Keynote or Gomez.
  • dev box – The first place performance testing happens (or should happen) is on the developer’s box. As she finishes her code changes, the developer can see if she made things better or worse. What was the impact of that JavaScript rewrite? What happens if I add another stylesheet, or split my images across two domains?

Performance metrics get less precise as you move from real user data to dev box testing, as shown in Figure 1. That’s because, as you move away from real user data, biases are introduced. For bucket testing, the challenge is selecting users in an unbiased way. For synthetic testing, you need to choose scenarios and test accounts that are representative of real users. Other variables of your real user audience are difficult or impossible to simulate: bandwidth speed, CPU power, OS, browser, geographic location, etc. Attempting to simulate real users in your synthetic testing is a slippery, and costly, slope. Finally, testing on the dev box usually involves one scenario on a CPU that is more powerful than the typical user, and an Internet connection that is 10-100 times faster.

Figure 1 - Precision and ability to iterate along the development process

Given this loss of precision, why would we bother with anything other than real user data? The reason is speed of development. Dev box data can be gathered within hours of a code change, whereas it can take days to gather synthetic data, weeks to do bucket testing, and a month or more to release the code and have real user data. If you wait for real user data to see the impact of your changes, it can take a year to iterate on a short list of performance improvements. To quickly identify the most important performance improvements and their optimal implementation, it’s important to improve our ability to gather performance metrics earlier in the development process: on the dev box.

As a developer, it can be painful to measure the impact of a code change on your dev box. Getting an accurate time measurement is the easy part; you can use YSlow, Fasterfox, or an alert dialog. But then you have to load the page multiple times. The most painful part is transcribing the load times into Excel. Were all the measurements done with an empty cache or a primed cache, or was that even considered?

Hammerhead makes it easier to gather performance metrics on your dev box. Figure 2 shows the results of hammering a few news web sites with Hammerhead. By virtue of being a Firebug extension, Hammerhead is available in a platform that web developers are familiar with. To setup a Hammerhead test, one or more URLs are added to the list, and the “# of loads” is specified. Once started, Hammerhead loads each URL the specified number of times.

Figure 2 - Hammerhead results for several news sites

Figure 2 - Hammerhead results for a few news web sites

The next two things aren’t rocket science, but they make a big difference. First, there are two columns of results, one for empty cache and one for primed cache. Hammerhead automatically clears the disk and memory cache, or just the memory cache, in between each page load to gather metrics for both of these scenarios. Second, Hammerhead displays the median and average time measurement. Additionally, you can export the data in CSV format.

Even if you’re not hammering a site, other features make Hammerhead a useful add-on. The Cache & Time panel, shown in Figure 3, shows the current URL’s load time. It also contains buttons to clear the disk and memory cache, or just the memory cache. It has another feature that I haven’t seen anywhere else. You can choose to have Hammerhead clear these caches after every page view. This is a nice feature for me when I’m loading the same page again and again to see it’s performance in an empty or a primed cache state. If you forget to switch this back, it gets reset automatically next time you restart Firefox.

Figure 3 - Cache & Time panel in Hammerhead

Figure 3 - Cache & Time panel in Hammerhead

If you don’t have Hammerhead open, you can still see the load time in the status bar. Right clicking the Hammerhead icon gives you access for clearing the cache. The ability to clear just the memory cache is another valuable feature I haven’t seen elsewhere. I feel this is the best way to simulate the primed cache scenario, where the user has been to your site recently, but not during the current browser session.

Hammerhead makes it easier to gather performance metrics early in the development process, resulting in a faster development cycle. The biggest bias is that most developers have a much faster bandwidth connection than the typical user. Easy-to-install bandwidth throttlers are a solution. Steve Lamm blogged on Google Code about how Hammerhead can be used with bandwidth throttlers on the dev box, bringing together both ease and greater precision of performance measurements. GIve it a spin and let me know what you think.

54 Comments

Ugly Doll at the Ajax Experience

September 30, 2008 1:45 pm | 3 Comments

My six year old daughter snuck her purple hippo in my bag when I went to SXSW in February. It provided a way for us to stay in touch even with time zone differences and busy schedules. I would take pictures of the purple hippo with my iPhone and email them back home. She and the rest of the family could see where the purple hippo was at the conference, and it was likely I was there, too. The photos made for a fun blog post: Purple Hippo at SXSW.

When I arrived at The Ajax Experience, I found her Ugly Doll at the bottom of my suitcase. I smiled. Let the games begin.

First things first, Ugly Doll checked to see if there was free wifi in the room. Answer? Negative. $12.95 later and we started catching up on email. It was late so Ugly Doll checked out the bed. Verdict? Thumbs up.

The first day was great – I attended talks from beginning to end (rare for me). Ben and Dion started with an intro Ajax tutorial – nice way to ease into the morning. John Resig followed with a comparison of jQuery, Dojo, MooTools, Prototype, and YUI – an even-handed comparison useful for anyone starting the selection process. Ben and Dion had an informative and fun romp through the Ajax Universe. This was the best talk of the day for me. They spiced it up by switching speakers based on a timer that went off at random intervals every 10 seconds to 2 minutes. Ojan Vafai presented Google Chrome. The day ended with PPK leading a panel comprised of representatives from the major JavaScript libraries: John Resig (jQuery), Dylan Schiemann (Dojo), Christian Heilmann (YUI), and Andrew Dupont (Prototype).

Dion Almaer and Ben Galbraith, Christian Heilmann, John Resig.

The highlight of the second day were the lightning talks. Stoyan Stefanov and Nicole Sullivan announced Smush it – an image optimization tool that looks extremely useful. I did a talk about Episodes – a proposal for measuring performance in Web 2.0 apps. Bill Scott talked about the upcoming release of the Netflix API, and Gavin Doughtie talked about interviewing JavaScript gurus. Brendan Eich delivered a keynote on JavaScript speed, and PPK had a good presentation on browser incompatability patterns.

Bill Scott, Gavin Doughtie, Doug Crockford.

There’s still another day of TAE remaining, but I have to get this post out today to leave room for a new post tomorrow. I’m looking forward to Ask The Experts with Brendan Eich, Douglas Crockford, John Resig, Joe Walker and Dylan Schiemann. On Wednesday I deliver a talk that includes a release of a new tool. Stay tuned!

3 Comments

First Week of Classes

September 26, 2008 11:48 pm | 4 Comments

I finished my first week teaching CS193H High Performance Web Sites at Stanford. It went well. The class is settling in at 35 students plus another 10 watching remotely through the Stanford Center for Professional Development. It’s 2/3 undergrad, 1/3 grad. The students are smart and ask great questions.

I’ve laid out the class schedule for the quarter. I post the slides before each lecture. Here are links to the slides from this week’s classes:

  • Introduction (ppt, GDoc)
  • The Importance of Frontend Performance (ppt, GDoc)
  • HTTP and Web 100 Performance Profile (ppt, GDoc)

Today we kicked off the first class project. Each student picks five top web sites and records different performance stats in our Web 100 Performance Profile spreadsheet. We’ll update this again at the end of the quarter and analyze any trends.

I’m traveling to Boston next week for The Ajax Experience and won’t be able to teach class. I’m excited to say I’ve lined up three great industry leaders, speakers, and friends to appear as guest lecturers. Joseph Smarr (Plaxo) is doing a talk on “Performance Challenges for the Open Web”. Lindsey Simon (Google) is going to provide an introduction to CSS and talk about the balance between design and performance. Bill Scott (Netflix) has prepped a talk entitled “High Performance Examples from the Real World”, sure to contain great anecdotes and lessons learned from his work at Yahoo! and Netflix. Luckily the class is videotaped, so I can watch their classes when I get back.

See you in Boston!

4 Comments

SXSW: get out the vote

August 25, 2008 10:57 am | 3 Comments

I submitted a proposal for SXSW Interactive: Even Faster Web Sites. SXSW is in Austin, March 13-17, 2009. It’s a great conference with a wide variety of content. John Resig recently announced two talk proposals. Both look great. In the same way, I hope to add a bit more technical content to the conference. I did a book reading last year that was very well attended, so I think there are a significant number of developers attending the conference. This year I hope to relay more techniques for making web pages (especially Web 2.0 pages) faster. The way SXSW works, talks are selected based on votes. If you think it would be good for SXSW, please add a comment by August 29 in support of my talk.

3 Comments

OSCON: 34 hours in 37 minutes

July 29, 2008 1:14 pm | Comments Off on OSCON: 34 hours in 37 minutes

I was in Portland for OSCON last week. There were many talks that attracted my attention – so many that I couldn’t get to them all. If you missed some talks, or didn’t make it to OSCON, check out this great effort capturing Oscon in 37 minutes. Gregg Pollack asked 45 speakers to summarize their talk in 30 seconds. Most people took longer (37 * 60 / 45 = 49.3 seconds), but still, to get a taste of 45 sessions in a 37 minute video is pretty awesome. If you had attended each session it would’ve taken over 34 hours! You can jump straight to the segment for any speaker (here’s mine), and links to each speaker’s slides are displayed.

Comments Off on OSCON: 34 hours in 37 minutes

Firebug Lite 1.2 Released

July 25, 2008 12:14 am | 10 Comments

Today Firebug Lite 1.2 was released. This new version was built by Azer Koçulu, creator of pi.debugger. Azer joined the Firebug Working Group, morphed the GUI to look like Firebug, and added it to the Firebug code base.

Firebug Lite is a subset of Firebug that can be used in IE, Opera, and Safari. The previous version provided console.log functionality. In Firebug Lite 1.2, Azer added the ability to inspect DOM elements, track XHRs, and navigate HTML, CSS, and JavaScript. You can embed it in your pages and enable debugging. I prefer creating a Firebug Lite bookmarklet that I can launch on any web page. Instructions and more information are available on the main Firebug Lite page.

I was able to demo this at OSCON today thanks to the folks from Mozilla who are now working on Firebug. As John Resig posted last week, he, Rob Campbell, and Jan Odvarko are going to be focusing on Firebug. Just one week later the benefits from their involvement are already being seen, as Rob quickly got the updates hosted on getfirebug.com. The roadmap for Firebug will be discussed at the upcoming Firefox Summit and the next Firebug Working Group meeting at Google in early August. I’ve been working with Azer testing his releases over the last month. It’s great to have Firebug functionality when I drop into IE. Thanks Azer and Rob!

10 Comments

See You at OSCON

July 18, 2008 10:14 pm | Comments Off on See You at OSCON

I’ll be up at OSCON in Portland this week. I’m speaking Thursday 2:35pm on Even Faster Web Sites, the next set of performance best practices I’m working on. I’m signing books Thursday 12:20pm at the Powells table, and I’ll be in the Google booth Thursday 4pm. At the Google booth I’ll be doing performance consulting – anyone can stop by and ask questions about their web site’s performance, or we can just fire up a packet sniffer and YSlow to see what jumps out.

There are a lot of great talks this year. Here are a few I’ve earmarked:

If you’re going to OSCON please come by and say Hi.

Comments Off on See You at OSCON

Women are Geeks (too!)

July 12, 2008 11:13 am | Comments Off on Women are Geeks (too!)

As a father of three girls I watch for indicators of the level to which women are represented in the tech community. I decided to write a blog post about this while sitting at the ACM Awards Banquet a week ago. My experience coming from tech companies, including Yahoo! and Google, is that women are incredibly, and sadly, underrepresented in engineering. That’s why I was pleased to see that so many of the ACM award winners were women. I generated a chart showing the number of woman ACM award winners over the last 30 years. It’s a small sample size, so I plotted the moving average to smooth out the spikes.

ACM Woman Awardees

I’m happy to see the number of woman awardees is increasing, with a real jump in the last two years. But I have two reservations. The percentage of woman winners is low, averaging only 5% over the last 30 years with a spike to 10% in the last two years. Also, most ACM award winners come from academia. I’m concerned that an analysis of similar award winners from industry would reveal even lower percentages for women. (more…)

Comments Off on Women are Geeks (too!)

Velocity Wrap-up

June 26, 2008 10:51 am | 3 Comments

This week I co-chaired Velocity, the web performance and operations conference from O’Reilly. It was great! Jesse and I told the story about how the conference came about. When we proposed the conference we believed there was a community of performance and operations engineers that needed a forum to share and learn, and the attendance at Velocity confirmed this. Velocity sold out with over 600 attendees!

The lineup of speakers was great. There was a lot of material packed in a 2-day conference. I stayed in the Performance track, but wanted to attend every session in the Operations track, too. Many speakers shared their slides, and there are videos and photos from some of the talks.

(more…)

3 Comments

Splitting the Initial Payload

May 14, 2008 3:09 pm | 13 Comments

This post is based on a chapter from Even Faster Web Sites, the follow-up to High Performance Web Sites. Posts in this series include: chapters and contributing authors, Splitting the Initial Payload, Loading Scripts Without Blocking, Coupling Asynchronous Scripts, Positioning Inline Scripts, Sharding Dominant Domains, Flushing the Document Early, Using Iframes Sparingly, and Simplifying CSS Selectors.

 

The growing adoption of Ajax and DHTML means today’s web pages have more JavaScript than ever before. The average top ten U.S. web site[1] contains 252K of JavaScript. JavaScript slows pages down. When the browser starts downloading or executing JavaScript it won’t start any other parallel downloads. Also, anything below an external script is not rendered until the script is completely downloaded and executed. Even in the case where external scripts are cached the execution time can still slow down the user experience and thwart progressive rendering.

Every line of JavaScript code matters to a fast loading page. And yet, as shown in Table 1, the average top ten U.S. web site only executes 25% of the JavaScript functionality before the onload event.[2] Why track this relative to the onload event? Any code needed after the onload event (for dropdown menus, Ajax requests, etc.) could be downloaded later, making the initial page render more quickly.

(more…)

13 Comments