Towards Parallelizing the Layout Engine of Firefox∗

Towards Parallelizing the Layout Engine of Firefox∗

Towards Parallelizing the Layout Engine of Firefox∗ Carmen Badea Mohammad R. Haghighat Alexandru Nicolau Alexander V. Veidenbaum UC Irvine Intel Corporation UC Irvine UC Irvine [email protected] [email protected] [email protected] [email protected] Abstract as such it is common to have computing resources sitting unused. The Mozilla Firefox browser currently accounts for ∼25% More recently, with the advancements in the web ap- of the total web browsers market segment share, estab- plication technology, the browser has emerged as the lishing itself as the second most popular browser world- favorite platform for deploying sophisticated applica- wide after Microsoft’s Internet Explorer. With the recent tions that were traditionally possible only as native adoption of a tracing JavaScript Just-In-Time (JIT) com- desktop applications (e.g., Google Docs and Zimbra piler in Firefox 3.5, its performance has improved signif- Collaboration Suite). However, among the most pop- icantly, especially for web pages that make heavy use of ular browsers, there are only a few that actually take JavaScript. Currently, the heavy performance hitter com- advantage of the available cores in their various com- ponent of Firefox is its layout engine. According to our ponents. The Chrome browser is one such browser, extensive performance measurements and analysis on rep- by treating each tab as a separate process (including resentative applications running on Intel platforms, the any JavaScript code being executed in a tab), thus layout engine of Firefox accounts for ∼40% of its total ex- naturally lending itself to parallelism. ecution time, with the Cascading Style Sheets (CSS) rule- Among the open-source browsers, Mozilla Firefox is matching process being the hot part of layout. We have currently the most widely used one. According to [2], developed a tracing and profiling mechanism that has en- as of April 2010 Firefox accounts for ∼25% of the to- abled us gain in-depth insight into the CSS rule-checking tal browsers market share, second only to Microsoft’s runtime characteristics. This data has proven extremely Internet Explorer in terms of usage, as shown in Fig- helpful in determining that the CSS rule-matching com- ure 1. ponent is a suitable target for parallelization. The col- lected trace information has also guided us to an effective parallel implementation of the Firefox CSS rule-matching component that delivers large performance speedups on popular web pages, including almost 90% of Mozilla’s page-load tests that comprise ∼400 distinct web pages from all over the world. For these tests, the entire page- load process shows performance changes ranging from - Figure 1: Browser market share distribution, as of April 2010 0.5x to +1.84x, with an average improvement of ∼1.1x, when two worker threads cooperate in doing the layout. To our knowledge, this is the first fully functional par- With the recent adoption of the tracing JIT allel implementation of CSS rule matching that delivers JavaScript engine (code-named TraceMonkey [5]) in significant speedups in a world-class browser. the Firefox 3.5 browser, its performance has im- proved significantly, especially for web pages that 1 Motivation make heavy use of JavaScript. Our extensive per- formance experiments show that currently the heavy Multi-core processors have gained widespread use in performance hitter component in the Firefox browser general-purpose systems and are expected to prolif- in many real usage cases is its layout engine, with the erate in embedded devices as well. However, many of Cascading Style Sheets(CSS) rule-matching compo- the popular applications run by end users do not take nent accounting for the largest portion of the layout advantage of the available hardware parallelism, and engine execution time (more details in Section 2.2). ∗This work was supported in part by the National Science Moreover, by incorporating our tracing and profiling Foundation under grant NSF CCF-0811882. mechanism into the Firefox’s CSS rule-checking com- 1 ponent, we were able to identify performance bottle- necks and determine that the rule-matching process is a suitable target for parallelization. The in-depth profiling and tracing data obtained proved to be of utmost importance in our develop- ment of the first fully-functional parallel implemen- Figure 2: General CSS rule structure and a simple CSS rule tation of CSS rule matching in a real browser. As example we will show in the upcoming Section 3, our par- allelized Firefox prototype yields considerable per- formance speedups despite thread management over- class selectors, and attribute selectors among others head and unavoidable speculative execution (for more (for more details, see [10]). To explain how the CSS details, see Section 2.3). rule-matching process works, we will use the sample The rest of this paper is organized as follows: in Sec- HTML document tree shown in Figure 3 and the fol- tion 2 we will give a brief overview of how the CSS lowing sample rule : ul em {color: blue}. For process works in general and how it is implemented in the web document using this CSS rule (which is a the Firefox browser in particular. We will also show descendant selector rule), any <em> element that is the profiling and tracing data indicating that the CSS contained in a <ul> element (i.e., the <ul> element rule-matching component is a heavy performance hit- is an ancestor of the <em> element in the web docu- ter in Firefox, as well as amenable to parallelization ment’s tree) will be colored blue. This matching pro- and we will discuss the parallelization strategy we cess is illustrated in Figure 3, with the <em> element used in developing the CSS rule-matching parallelized that will potentially be colored blue being the hashed prototype in Firefox. Section 3 illustrates the perfor- node in the figure and its ancestors being the lighter mance speedups obtained by carrying out browsing colored nodes in the highlighted path from the <em> experiments using our parallelized prototype. Sec- element up to the root of the tree. The matching pro- tion 4 reviews other projects related to our research, cess is carried bottom up, starting with the parent of followed by a brief summary of the work presented in the <em> element, until either a match is found or the this paper in Section 5. root of the document tree has been reached and no match has been found. 2 Methodology In this section we will discuss the approach we took for developing a parallelized version of the CSS rule- matching component in Firefox and we begin by giv- ing a brief review of how CSS works in general. 2.1 CSS Overview Cascading Style Sheets (CSS) [10] represent a style- sheet language used for describing the presentation semantics of web pages. It offers a way of provid- ing clean separation between webpage content (e.g., HTML) and its presentation (e.g., fonts, colors, spac- ing, etc.). CSS allows multiple webpages to share for- matting characteristics, reduces the amount of repe- tition in specifying layout styles, and makes it easy Figure 3: CSS rule-matching example on a sample HTML to apply style changes in the possibly large number document tree of web pages of a given site. The desired layout fea- tures are expressed through CSS rules. Figure 2 il- Since in the rest of the paper we will mostly refer lustrates the general format of CSS rules, as well as a to descendant and sibling selectors, we will briefly de- very simple example: a CSS rule that will apply the scribe how they work. black color to the <body> element of the web docu- A descendant selector is formed by two or more sim- ment that uses this CSS declaration, as well a 1em ple selectors that are separated by white space. The padding1. There are many types of selectors, such as general form of such a selector is ’A B’ and it will descendant selectors, sibling selectors, child selectors, match when an element of type B is a descendant- 1Figure courtesy of http://css.maxdesign.com.au of/contained-in an element of type A. 2 Similarly, an (adjacent) sibling selector is made up #Occurrences Pattern %iterations covered of two or more selectors separated by +. For a rule 5561595 p3 2.93 of the form A + B, this selector will match if A and 1997994 pppppppppppn1 13.43 B have the same parent in the document tree and A 1977238 pppppppppppn1 24.88 immediately precedes B. 1846126 pn3 25.85 1599769 ppppppppn1 32.58 2.2 Profiling Strategy and Results 1530957 pppppppppn1 39.83 Before doing any parallelization, we needed to deter- 1293911 ppppppppppppn1 47.99 mine which Firefox component(s) accounted for large 1187742 pppppppn1 52.37 amounts of the browser execution time. According to 840304 ppppppn1 55.02 our extensive VTune [1] experiments on many Intel 619361 pppppppppppppn1 59.25 platforms, the layout engine of Firefox is its heavy 550482 ppppppppppppppn1 63.31 hitter performance component. For example, on In- 418940 pppppppppppppppn1 66.61 tel Atom platform, the layout component accounted 382272 ppppppppppppppppn1 69.83 for ∼40% of the total browser execution time, while 310138 pppppn1 70.65 the JavaScript execution engine covered only ∼13%. Further profiling showed that the CSS rule-matching Table 1: Most frequent execution patterns observed during process represents the hot part of the layout en- CSS rule matching on Firefox page-load tests gine. The top two most executed functions of the layout engine, that account for an overall ∼32% of the execution time of the layout engine, were the We found that in the CSS rule-matching process of SelectorMatches and SelectorMatchesTree func- typical web pages, not only are the selectors heavily tions, which are the most important components biased towards one particular type (namely descen- of the CSS rule-matching process.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us