Boost thread priority while loading libraries on background thread
This CL is adding a priority boost to code that can potentially load
a DLL on a background thread.
As describe on crbug/973868, loading DLL on a backgrounded thread may
cause a priority inversion on the loader lock. It is the source of
the 99th percentile jank.
The jank was detected by using slow-reports. The list of sites that
can load DLL was collected through an instrumentation in InspectModule
code.
[email protected], [email protected]
Bug: 973868
Change-Id: I3b040fa04187a52d4eaa74552ea7695dbb03c3f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1658856
Reviewed-by: Bruce Dawson <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Jan Wilken Dörrie <[email protected]>
Reviewed-by: Nathan Parker <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Asanka Herath <[email protected]>
Reviewed-by: François Doray <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Commit-Queue: Etienne Bergeron <[email protected]>
Cr-Commit-Position: refs/heads/master@{#670519}
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 7266d9e..8844ee4 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -32,6 +32,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/scoped_blocking_call.h"
+#include "base/threading/scoped_thread_priority.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/win/registry.h"
@@ -751,6 +752,10 @@
int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
const base::FilePath& path) {
+ // Mitigate the issues caused by loading DLLs on a background thread
+ // (http://crbug/973868).
+ base::ScopedThreadMayLoadLibraryOnBackgroundThread priority_boost(FROM_HERE);
+
// Enumerate all pinned shortcuts in the given path directly.
base::FileEnumerator shortcuts_enum(
path, false, // not recursive