blob: fe1fdff4858524a1b70f68abbc87ff8210798983 [file] [log] [blame]
Daniel Dunbar2336d1f2008-11-01 01:14:36 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
5 <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
6 <title>Clang - Performance</title>
7 <link type="text/css" rel="stylesheet" href="menu.css" />
8 <link type="text/css" rel="stylesheet" href="content.css" />
9 <style type="text/css">
10</style>
11</head>
12<body>
13
14<!--#include virtual="menu.html.incl"-->
15
16<div id="content">
17
18<!--*************************************************************************-->
19<h1>Clang - Performance</h1>
20<!--*************************************************************************-->
21
22<p>This page tracks the compile time performance of Clang on two
23interesting benchmarks:
24<ul>
25 <li><i>Sketch</i>: The Objective-C example application shipped on
26 Mac OS X as part of Xcode. <i>Sketch</i> is indicative of a
27 "typical" Objective-C app. The source itself has a relatively
28 small amount of code (~7,500 lines of source code), but it relies
29 on the extensive Cocoa APIs to build its functionality. Like many
30 Objective-C applications, it includes
31 <tt>Cocoa/Cocoa.h</tt> in all of its source files, which represents a
32 significant stress test of the front-end's performance on lexing,
33 preprocessing, parsing, and syntax analysis.</li>
34 <li><i>176.gcc</i>: This is the gcc-2.7.2.2 code base as present in
35 SPECINT 2000. In contrast to Sketch, <i>176.gcc</i> consists of a
36 large amount of C source code (~220,000 lines) with few system
37 dependencies. This stresses the back-end's performance on generating
38 assembly code and debug information.</li>
39</ul>
40</p>
41
42<!--*************************************************************************-->
43<h2><a name="enduser">Experiments</a></h2>
44<!--*************************************************************************-->
45
46<p>Measurements are done by serially processing each file in the
47respective benchmark, using Clang, gcc, and llvm-gcc as compilers. In
48order to track the performance of various subsystem, the timings have
49been broken down into separate stages where possible:
50
51<ul>
52 <li><tt>-Eonly</tt>: This option runs the preprocessor but does not
53 perform any output. For gcc and llvm-gcc, the -MM option is used
54 as a rough equivalent to this step.</li>
55 <li><tt>-parse-noop</tt>: This option runs the parser on the input,
56 but without semantic analysis or any output. gcc and llvm-gcc have
57 no equivalent for this option.</li>
58 <li><tt>-fsyntax-only</tt>: This option only runs semantic
59 analysis.</li>
60 <li><tt>-emit-llvm -O0</tt>: For Clang and llvm-gcc, this option
61 converts to the LLVM intermediate representation but doesn't
62 generate native code.</li>
63 <li><tt>-S -O0</tt>: Perform actual code generation to produce a
64 native assembler file.</li>
65 <li><tt>-S -O0 -g</tt>: This adds emission of debug information to
66 the assembly output.</li>
67</ul>
68</p>
69
70<p>This set of stages is chosen to be approximately additive, that is
71each subsequent stage simply adds some additional processing. The
72timings measure the delta of the given stage from the previous
73one. For example, the timings for <tt>-fsyntax-only</tt> below show
74the difference of running with <tt>-fsyntax-only</tt> verse running
75with <tt>-parse-noop</tt> (for clang) or <tt>-MM</tt> with gcc and
76llvm-gcc. This amounts to a fairly accurate measure of only the time
77to perform semantic analysis (and parsing, in the case of gcc and llvm-gcc).</p>
78
79<!--*************************************************************************-->
80<h2><a name="enduser">Timing Results</a></h2>
81<!--*************************************************************************-->
82
83<!--=======================================================================-->
84<h3><a name="2008-10-31">2008-10-31</a></h3>
85<!--=======================================================================-->
86
87<center><h4>Sketch</h4></center>
88<img class="img_slide"
89 src="timing-data/2008-10-31/sketch.png" alt="Sketch Timings"/>
90
91<p>This shows Clang's substantial performance improvements in
92preprocessing and semantic analysis; over 90% faster on
93-fsyntax-only. As expected, time spent in code generation for this
94benchmark is relatively small. One caveat, Clang's debug information
95generation for Objective-C is very incomplete; this means the <tt>-S
96-O0 -g</tt> numbers are unfair since Clang is generating substantially
97less output.</p>
98
99<p>This chart also shows the effect of using precompiled headers (PCH)
100on compiler time. gcc and llvm-gcc see a large performance improvement
101with PCH; about 4x in wall time. Unfortunately, Clang does not yet
102have an implementation of PCH-style optimizations, but we are actively
103working to address this.</p>
104
105<center><h4>176.gcc</h4></center>
106<img class="img_slide"
107 src="timing-data/2008-10-31/176.gcc.png" alt="176.gcc Timings"/>
108
109<p>Unlike the <i>Sketch</i> timings, compilation of <i>176.gcc</i>
110involves a large amount of code generation. The time spent in Clang's
111LLVM IR generation and code generation is on par with gcc's code
112generation time but the improved parsing & semantic analysis
113performance means Clang still comes in at ~29% faster verse gcc
114on <tt>-S -O0 -g</tt> and ~20% faster verse llvm-gcc.</p>
115
116<p>These numbers indicate that Clang still has room for improvement in
117several areas, notably our LLVM IR generation is significantly slower
118than that of llvm-gcc, and both Clang and llvm-gcc both incur a
119significantly higher cost for adding debugging information compared to
120gcc.</p>
121
122</div>
123</body>
124</html>