Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 02e86e63291c1efc71da8f1be4002f2fe2626768
      
https://github.com/WebKit/WebKit/commit/02e86e63291c1efc71da8f1be4002f2fe2626768
  Author: Jer Noble <[email protected]>
  Date:   2025-10-04 (Sat, 04 Oct 2025)

  Changed paths:
    M Source/WebKit/Platform/LogClient.cpp
    M Source/WebKit/Platform/LogClient.h
    M Source/WebKit/Scripts/generate-derived-log-sources.py
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  [Build Speed] Make WebKit/LoggingClient.h less expensive to include
rdar://161924655
https://bugs.webkit.org/show_bug.cgi?id=300147

Reviewed by Per Arne Vollan.

Prior to this patch, LogClient.h was the 4th most expensive header used in 
WebKit; it was included
266 times in a WebKit Unified build, and on this machine each include of that 
file took the
compiler 930ms to parse, for a total of 4.1m CPU minutes of time spent parsing 
this header.

The high cost of this header occurs because nearly the entire implementation is 
inlined. The
generate-derived-log-sources.py produces code which can only exist in the 
header of the class, and
the templated send() method which sends log messages out-of-process must also 
exist in the header.

Restructure the way these log messages are generated using pre-processor 
macros. This allows the
derived sources step to generate message names and arguments, but allows the 
structure of the
implementation to be decided by clients. The log messages generate a macro 
which will apply another
preprocessor macro to each message in turn. This is similar to how Logging.h or 
SoftLinking.h
headers work in other parts of the project.

The WebKitLogClientMessageDefinitions.h and WebCoreLogClientMessageDefinitions.h
header files will now contain a macro which looks like this:

    M(SUBRESOURCELOADER_DIDFINISHLOADING, (uint64_t arg0, uint64_t arg1, 
uint64_t arg2), (arg0, arg1, arg2)) \
...

LogClient.h will generate method declarations by passing a macro into
`WEBCORE_LOG_CLIENT_MESSAGES()`, which will turn the macro above into:

    void SUBRESOURCELOADER_DIDFINISHLOADING(uint64_t arg0, uint64_t arg1, 
uint64_t arg2);

LogClient.cpp will generate method implementation by passing a macro into
`WEBCORE_LOG_CLIENT_MESSAGES()`, which will turn the macro above into:

void LogClient::SUBRESOURCELOADER_DIDFINISHLOADING(uint64_t arg0, uint64_t 
arg1, uint64_t arg2)
{
    send(Messages::LogStream::SUBRESOURCELOADER_DIDFINISHLOADING(arg0, arg1, 
arg2));
}

This allows the LogClient.h header to have it's parse time significantly reduced
by moving all implementation details into the .cpp file.

After this patch, LogClient.h is now the 124th most expensive header file used 
in WebKit; it is
included 268 times, for a total of 12s CPU seconds of time spent parsing this 
header, a reduction
of 3.9m.

* Source/WebKit/Platform/LogClient.cpp:
(WebKit::LogClient::send):
* Source/WebKit/Platform/LogClient.h:
(WebKit::LogClient::send): Deleted.
* Source/WebKit/Scripts/generate-derived-log-sources.py:
(generate_log_client_declarations_file):
(main):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/301009@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to