-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PGO] Fix sandboxing issues and simplify collection
https://bugs.webkit.org/show_bug.cgi?id=261014 rdar://113870737 Reviewed by Justin Michaud and Alexey Proskuryakov. Make a number of simplifications to our PGO instrumentation logic to fix instances where profile collection would fail silently due to sandboxing: Instead of initializing and writing out instrumented profiles ourselves, use LLVM's built-in logic. We bake in a default profile path into instrumented binaries, which tells the instrumentation machinery to write profiles to /private/tmp/WebKitPGO. This is done by declaring __llvm_profile_filename in each instrumented binary, rather than using the -fprofile-generate=<name> compiler argument, because there is no Xcode build setting to easily set it, see rdar://114792050. At process launch, profiling begins via a static initializer compiled in to each instrumented binary from LLVM. Auto-initalization works great for starting PGO collection in a predictably, across all WebKit processes, but termination requires extra care. On Darwin-based platforms, we kill WebKit XPC processes via _exit, without running atexit handlers, which is normally when profiles would be written. To accomodate this, run profile collection in "continuous mode", denoted by a %c in the profile string. LLVM mmaps the profile file and records function calls directly in the mapped file, with no writeback step needed. Add sandbox rules to permit writing to the WebKitPGO directory when built for instrumentation. Teach the benchmark runner to copy from WebKitPGO when Safari exits, instead of parsing the system log to find written profiles. * Source/JavaScriptCore/runtime/InitializeThreading.cpp: Declare default profile name for JSC. * Source/WTF/WTF.xcodeproj/project.pbxproj: Remove GenerateProfiles.h. * Source/WTF/wtf/CMakeLists.txt: Remove GenerateProfiles.h. * Source/WTF/wtf/GenerateProfiles.h: Removed. * Source/WebCore/bindings/js/ScriptController.cpp: Declare default profile name for WebCore. * Source/WebKit/Configurations/BaseXPCService.xcconfig: XPC executables (i.e. the binary that contains XPCServiceMain) were being instrumented, but the profiles were being discarded due to sandboxing. We can safely turn off instrumentation -- the only binaries we care about are the executables in the WebKit framework stack. * Source/WebKit/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in: Allow access to the WebKitPGO directory. * Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: Ditto. * Source/WebKit/Shared/Cocoa/WebKit2InitializeCocoa.mm: Declare default profile name for WebKit. * Source/WebKit/Shared/WebKit2Initialize.cpp: Remove spurious include. * Source/WebKit/WebProcess/com.apple.WebProcess.sb.in: Ditto above. * Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py: When collecting profiles, each invocation will populate /tmp/WebKitPGO. Ensure the directory is empty before launching the browser, and copy its contents to the diagnostic directory upon exit. (BenchmarkRunner._run_benchmark): * Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py: (run_benchmark_plan): Use a fixed path for writing profiles to. * Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py: (WebServerBenchmarkRunner._get_result): Remove the logic that listened to the system log for profiling messages and moved profiles out ad hoc. * Tools/TestWebKitAPI/Configurations/TestIPC.xcconfig: It static-links libWebKitPlatform.a, so when that library is compiled with profiling it needs it too. This has likely always been broken, and not been an issue since we never attempt to build for profiling with tools. Canonical link: https://commits.webkit.org/267741@main
- Loading branch information
Showing
14 changed files
with
36 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters