Skip to content

Commit d84e301

Browse files
committed
[Build Speed] Break up DocumentInlines.h
rdar://161694748 https://bugs.webkit.org/show_bug.cgi?id=299920 Reviewed by Ryosuke Niwa. Prior to this patch, DocumentInlines.h was the most expensive header used in WebCore; it is included 303 times in a WebCore Unified build, and on this machine, each include of that file too the compile on average 1.5s to parse, for a total of 8m CPU minutes of time spent parsing this header. To diagnose why this header is so expensive, I commented out all the implementations from the body of this header and ran a compile, collecting a list of all the errors encountered. I then collected the counts of each error message, and grouped liked errors together. It became clear that most uses of DocumentInlines.h were to pull in a very narrow set of inlined methods, but to get those few methods had to include a very large and very heavy header. To address this, DocumentInlines.h was broken up into separate headers, each which includes only Document.h and one or two other headers. Usually the second header was required to define the return type of the method, and the type definition is required because the return type is a CheckedPtr or RefPtr. However because the return value is typically used at the call site, that return value header would have been included already, meaning this style of header has zero effective additional cost. The files were created in descending order of the number of uses: - DocumentView.h - 187 - DocumentPage.h - 175 - DocumentQuirks.h - 84 - DocumentSecurityOrigin.h - 54 - DocumentResourceLoader.h - 49 - DocumentMarkers.h - 27 - DocumentEventLoop.h - 26 - DocumentSettingsValues.h - 23 - DocumentWindow.h - 19 The remaining grab-bag of inlined methods had less than 10 uses each and were left in DocumentInlines.h. After this patch, DocumentInlines.h is used in just over 100 implementation files and no headers. None of the new Document*.h headers or DocumentInlines.h appear in the top 100 most expensive header files. DocumentInlines.h dropped from the #1 most expensive header taking 8m to parse to #389 and 5.7s of parsing. The most expensive new header is DocumentPage.h at #124 and 25s of parsing. Canonical link: https://commits.webkit.org/300989@main
1 parent ac8c421 commit d84e301

611 files changed

Lines changed: 1421 additions & 990 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/WebCore/Headers.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,16 +1332,25 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
13321332
dom/Document.h
13331333
dom/DocumentClasses.h
13341334
dom/DocumentEnums.h
1335+
dom/DocumentEventLoop.h
13351336
dom/DocumentEventTiming.h
13361337
dom/DocumentFontLoader.h
13371338
dom/DocumentFragment.h
13381339
dom/DocumentFullscreen.h
13391340
dom/DocumentInlines.h
13401341
dom/DocumentMarker.h
13411342
dom/DocumentMarkerController.h
1343+
dom/DocumentMarkers.h
1344+
dom/DocumentPage.h
13421345
dom/DocumentParser.h
1346+
dom/DocumentQuirks.h
1347+
dom/DocumentResourceLoader.h
1348+
dom/DocumentSecurityOrigin.h
1349+
dom/DocumentSettingsValues.h
13431350
dom/DocumentStorageAccess.h
13441351
dom/DocumentType.h
1352+
dom/DocumentView.h
1353+
dom/DocumentWindow.h
13451354
dom/DragEvent.h
13461355
dom/Element.h
13471356
dom/ElementAncestorIterator.h

Source/WebCore/Modules/ShapeDetection/BarcodeDetector.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@
3030
#include "BarcodeFormat.h"
3131
#include "Chrome.h"
3232
#include "DetectedBarcode.h"
33-
#include "DocumentInlines.h"
33+
#include "DocumentPage.h"
3434
#include "ImageBitmap.h"
3535
#include "ImageBitmapOptions.h"
3636
#include "ImageBuffer.h"
3737
#include "JSDOMPromiseDeferred.h"
3838
#include "JSDetectedBarcode.h"
39-
#include "Page.h"
4039
#include "ScriptExecutionContext.h"
4140
#include "WorkerGlobalScope.h"
4241

Source/WebCore/Modules/ShapeDetection/FaceDetector.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include "Chrome.h"
3030
#include "DetectedFace.h"
31-
#include "DocumentInlines.h"
3231
#include "FaceDetectorOptions.h"
3332
#include "ImageBitmap.h"
3433
#include "ImageBitmapOptions.h"

Source/WebCore/Modules/ShapeDetection/TextDetector.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include "Chrome.h"
3030
#include "DetectedText.h"
31-
#include "DocumentInlines.h"
3231
#include "Document.h"
3332
#include "ImageBitmap.h"
3433
#include "ImageBitmapOptions.h"

Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "ApplePayAMSUIRequest.h"
3232
#include "ContextDestructionObserverInlines.h"
33-
#include "DocumentInlines.h"
33+
#include "DocumentPage.h"
3434
#include "JSApplePayAMSUIRequest.h"
3535
#include "JSDOMConvert.h"
3636
#include "Page.h"

Source/WebCore/Modules/applepay/ApplePaySession.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
#include "ApplePayShippingMethodUpdate.h"
4747
#include "ApplePayValidateMerchantEvent.h"
4848
#include "ContextDestructionObserverInlines.h"
49-
#include "DocumentInlines.h"
5049
#include "DocumentLoader.h"
50+
#include "DocumentPage.h"
5151
#include "EventNames.h"
5252
#include "EventTargetInlines.h"
5353
#include "JSDOMPromiseDeferred.h"

Source/WebCore/Modules/applepay/ApplePaySetup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#if ENABLE(APPLE_PAY)
3030

3131
#include "ContextDestructionObserverInlines.h"
32-
#include "DocumentInlines.h"
32+
#include "DocumentPage.h"
3333
#include "JSApplePaySetupFeature.h"
3434
#include "JSDOMPromiseDeferred.h"
3535
#include "Page.h"

Source/WebCore/Modules/applepay/PaymentCoordinator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "ApplePayShippingMethod.h"
3636
#include "ApplePayShippingMethodUpdate.h"
3737
#include "Document.h"
38-
#include "DocumentInlines.h"
38+
#include "DocumentPage.h"
3939
#include "ExceptionDetails.h"
4040
#include "LinkIconCollector.h"
4141
#include "Logging.h"

Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "CSSPropertyParserConsumer+Color.h"
3232
#include "Color.h"
33-
#include "DocumentInlines.h"
33+
#include "DocumentPage.h"
3434
#include "SecurityOrigin.h"
3535
#include <JavaScriptCore/ConsoleMessage.h>
3636
#include <optional>

Source/WebCore/Modules/async-clipboard/Clipboard.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "ClipboardItem.h"
3131
#include "CommonAtomStrings.h"
3232
#include "ContextDestructionObserverInlines.h"
33-
#include "Document.h"
33+
#include "DocumentPage.h"
3434
#include "Editor.h"
3535
#include "EventTargetInterfaces.h"
3636
#include "FrameInlines.h"
@@ -39,7 +39,6 @@
3939
#include "JSDOMPromiseDeferred.h"
4040
#include "LocalFrameInlines.h"
4141
#include "Navigator.h"
42-
#include "Page.h"
4342
#include "PagePasteboardContext.h"
4443
#include "Pasteboard.h"
4544
#include "Settings.h"

0 commit comments

Comments
 (0)