Monday, December 20, 2010

Scrolling: Chrome vs Firefox

I was using the Chrome browser on my laptop the other day (some browser compat problem). I don't normally use it; Firefox is my preferred browser. I couldn't help but notice how peculiarly laggy it felt to use. It came down to vertical scrolling: this highly common task - for any long article you'll be doing a lot of it - felt jerky and unpleasant. So I did a quick ad-hoc experiment: open up the same web page in both browsers with viewports of the same size, grab the vertical scroll bar, and wiggle it up and and down continuously so the browser is constantly redrawing text.

This is a crop from Process monitor on my desktop machine, which has 8 logical cores, i.e. 4 physical cores with hyperthreading. That means that 100% CPU usage on one core shows up as 12.5% CPU usage. The big wide bump on the left is the CPU usage while I was fiddling with Chrome; the one on the right is Firefox. (The bump in the middle is sqlservr.exe, which wakes up and does meaningless busywork every 60 seconds.) You can see that Chrome uses perhaps 50% more CPU usage on this task than Firefox, with more time spent in the user process and (proportionately) less in the kernel (presumably shifting bits around). Eyeballing an average of CPU usage, Firefox ranged from 6% to 7.5%, while Chrome pegged at 12.5%. Chrome is simply less CPU-efficient redrawing while scrolling, and it's very obvious to my eyes. (I did the same experiment with IE, and it was in the middle, with about 9% CPU.)

I might hazard a guess that Firefox spends more memory on caching bitmaps of the web page, or some similar trick trading off space for time. In any case, it's one of the reasons Firefox is still my primary browser, and also why I'm completely unconcerned about its memory usage. I have yet to encounter significant paging because of Firefox, not least because it's a 32-bit process, limiting its maximum usage, and I have alternately 12G and 4G of memory in my primary desktop and laptop respectively.

Mind you, when I add up the private working set for all 8 chrome.exe processes apparently needed to display this web page, they add up to 86M, only 1M less than my recently restarted firefox.exe session at 87M. (Comparing other memory usage numbers is awkward, as non-working-set memory isn't relevant, while non-private memory would be double-counted with Chrome.)


Anonymous said...

You could probably start an instance of Chrome, load the web page and read the entire article in the time it takes Firefox just to start up :)

Linas said...

I can scroll very smoothly in my Chrome. Haven't noticed any difference in my Chrome and Firefox. Mostly chrome beats Firefox in terms of rendering speed IMO. I can even enable GPU acceleration to speed things up in Chrome.

Jolyon Smith said...

Using Chrome+ the utterly artificial scenario of constantly wiggling the scrollbar failed to tip either of my paltry 2 CPU cores over 25% utilisation on a page with a normal/typical amount of content.

On the TRON dedicated talkback page on AICN (with a LARGE amount of content!) the same articifial exercise yielded 50% on each core.

But day to day *actual* real world scrolling has never been noticeably poor on Chrome+ for me.

Maybe Chrome+ is better than Chrome... I doubt it in this area. But I also wonder how your graphics card is set up, latest drivers etc... CPU load related to performance in the graphics domain is more often than not laid at the feet of the driver, not the app (not always, but very often). Plus I seem to recall reading that the latest and greatest GFX hardware is great at 3D but (relatively) is also (or can be) lousy at 2D, since the emphasis at the high end is on gaming.

Barry Kelly said...

@Jolyon - Graphics card is ATI HD 5870, driver is 2 months old. But the results also bear out on both of my laptops, one a Mac Air (so Nvidia 320M), the other Intel GMA. That's all three most common graphics card chipsets, from high end to lowest end. The CPU is no slouch either, an i7 @ 3.4MHz.

The jerkiness of the scrolling is most noticeable with the middle mouse click scroll widget - the little 4-way scroll icon that pops up, and causes scrolling depending on how far the cursor is from the icon.

It's also highly noticeable on the laptops when scrolling long documents (Google Reader's "infinite" reading list is a good example) with the keyboard.

Again, this isn't about initial rendering speed, bringing up a web page - that is IMO a relatively unimportant statistic, as I find the limiting factor for page load to be bandwidth - but simply scrolling around.

And it's not artificial for me. I tend to always be nervously scrolling around, usually with the middle button, and highlighting text. Chrome just feels "off", "juddery".

Eric said...

I guess it all boils down to how you scroll. I personally turn off the scroll widget, as it pollutes the middle-click functionality, and rarely scroll with the scrollbar, preferring either keys or mouse wheel, and for those, I can't reproduce your cpu usage spike on any of my machines (a quad-core desktop, a dual-core laptop and an atom netbook).

I tried on the 599+ post mega-thread on 64bit in non-tech.

That said, there is another option that could play a role, it's the "smooth scrolling" or something like that in the OS, which I also turn off along with the rest of the OS transition animations (because I want my menus to popup instantly, not wait for a silly fade-in or animation).

Dorin Duminica said...

I'm surprised that you haven't tested Opera browser -- which IMHO is one of the best browsers, really fast!!

Eamon Nerbonne said...

Given the appearance and rapid development of GPU-accelerated rendering, I'm betting whatever finding holds now will not in six months.

In any case, I have the same finding - scrolling in chrome is juddery (particularly on CSS-heavy pages) and less so on FF. However, it's not always CPU-limited; sometimes it's spending just 2% of CPU time (less than FF), and it's still juddery - fairly consistently too, as if there's a frame-rate maximum hardcoded somewhere.

To those that think this doesn't matter: it does to me too. In fact, stuff like this present the most relevant performance benefit chrome has as well, such as switching between tabs or opening and closing them. UI latency matters; chrome's is generally excellent here and the small remaining issue of scrolling may well be addressed by hw-accel some time in the future.