From 0a1fa429b108c65452c3af1529e6a5535d9d707b Mon Sep 17 00:00:00 2001 From: robliao Date: Mon, 20 Apr 2015 11:01:51 -0700 Subject: [PATCH] Early Initialization Experiment for Extension APIs Extension API Startup takes 100-200 ms in the 75th percentile case on PreMainMessageLoop during extension initialization. This experiment early initializes this data on another thread to see if that would speed up the overall time. If this experiment goes well, we'll open an investigation to do a proper async framework for initialization. BUG=470743 Review URL: https://codereview.chromium.org/1060513003 Cr-Commit-Position: refs/heads/master@{#325874} --- chrome/browser/chrome_browser_main.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 34bce56bdd33..a76aad937985 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -120,6 +120,7 @@ #include "components/translate/content/common/cld_data_source.h" #include "components/translate/core/browser/translate_download_manager.h" #include "components/variations/net/variations_http_header_provider.h" +#include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -203,6 +204,7 @@ #if defined(ENABLE_EXTENSIONS) #include "chrome/browser/extensions/startup_helper.h" #include "extensions/browser/extension_protocols.h" +#include "extensions/common/features/feature_provider.h" #include "extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.h" #endif // defined(ENABLE_EXTENSIONS) @@ -1141,6 +1143,20 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); + +#if defined(ENABLE_EXTENSIONS) + if (!variations::GetVariationParamValue( + "LightSpeed", "EarlyInitStartup").empty()) { + // Try to compute this early on another thread so that we don't spend time + // during profile load initializing the extensions APIs. + BrowserThread::PostTask( + BrowserThread::FILE_USER_BLOCKING, + FROM_HERE, + base::Bind( + base::IgnoreResult(&extensions::FeatureProvider::GetAPIFeatures))); + } +#endif + // Android updates the metrics service dynamically depending on whether the // application is in the foreground or not. Do not start here. #if !defined(OS_ANDROID) -- 2.11.4.GIT