Commit b259c871 authored by vadimt's avatar vadimt Committed by Commit bot

Instrumenting internals of AccountIdFetcher::Start to locate the source of jankiness.

Previous instrumentations showed that AccountIdFetcher::Start
alone is responsible for 20.5 janks per hour in UI thread, with 203ms average
run time. I need to instrument
the code inside it to find out which part causes jank.

This is a mechanical change that adds instrumentation required to locate the
source of jankiness (i.e. a long-running fragment of code executed as a part of
the task that causes jank) in the code. See the bug for details on what kind of
jank we are after.
A number of similar CLs were landed, and none of them caused issues. They've
helped to find and fix janky code. The code of the instrumentation is highly
optimized and is not expected to affect performance. The code simply creates a
diagnostic task which is identical to ones created by PostTask or IPC message
handlers. The task gets created only in developer build and in Canary channel.

BUG=422460

Review URL: https://codereview.chromium.org/685033006

Cr-Commit-Position: refs/heads/master@{#302649}
parent ad8ae0f7
...@@ -214,6 +214,12 @@ OAuth2TokenService::Fetcher* OAuth2TokenService::Fetcher::CreateAndStart( ...@@ -214,6 +214,12 @@ OAuth2TokenService::Fetcher* OAuth2TokenService::Fetcher::CreateAndStart(
client_secret, client_secret,
scopes, scopes,
waiting_request); waiting_request);
// TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"422460 OAuth2TokenService::Fetcher::CreateAndStart"));
fetcher->Start(); fetcher->Start();
return fetcher; return fetcher;
} }
...@@ -461,6 +467,11 @@ OAuth2TokenService::StartRequestForClientWithContext( ...@@ -461,6 +467,11 @@ OAuth2TokenService::StartRequestForClientWithContext(
Consumer* consumer) { Consumer* consumer) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
// TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
tracked_objects::ScopedTracker tracking_profile1(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"422460 OAuth2TokenService::StartRequestForClientWithContext 1"));
scoped_ptr<RequestImpl> request(new RequestImpl(account_id, consumer)); scoped_ptr<RequestImpl> request(new RequestImpl(account_id, consumer));
FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_, FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_,
OnAccessTokenRequested(account_id, OnAccessTokenRequested(account_id,
...@@ -468,6 +479,11 @@ OAuth2TokenService::StartRequestForClientWithContext( ...@@ -468,6 +479,11 @@ OAuth2TokenService::StartRequestForClientWithContext(
scopes)); scopes));
if (!RefreshTokenIsAvailable(account_id)) { if (!RefreshTokenIsAvailable(account_id)) {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
tracked_objects::ScopedTracker tracking_profile2(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"422460 OAuth2TokenService::StartRequestForClientWithContext 2"));
GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP); GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_, FOR_EACH_OBSERVER(DiagnosticsObserver, diagnostics_observer_list_,
...@@ -488,6 +504,11 @@ OAuth2TokenService::StartRequestForClientWithContext( ...@@ -488,6 +504,11 @@ OAuth2TokenService::StartRequestForClientWithContext(
account_id, account_id,
scopes); scopes);
if (HasCacheEntry(request_parameters)) { if (HasCacheEntry(request_parameters)) {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
tracked_objects::ScopedTracker tracking_profile3(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"422460 OAuth2TokenService::StartRequestForClientWithContext 3"));
StartCacheLookupRequest(request.get(), request_parameters, consumer); StartCacheLookupRequest(request.get(), request_parameters, consumer);
} else { } else {
FetchOAuth2Token(request.get(), FetchOAuth2Token(request.get(),
...@@ -506,6 +527,11 @@ void OAuth2TokenService::FetchOAuth2Token(RequestImpl* request, ...@@ -506,6 +527,11 @@ void OAuth2TokenService::FetchOAuth2Token(RequestImpl* request,
const std::string& client_id, const std::string& client_id,
const std::string& client_secret, const std::string& client_secret,
const ScopeSet& scopes) { const ScopeSet& scopes) {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"422460 OAuth2TokenService::FetchOAuth2Token"));
// If there is already a pending fetcher for |scopes| and |account_id|, // If there is already a pending fetcher for |scopes| and |account_id|,
// simply register this |request| for those results rather than starting // simply register this |request| for those results rather than starting
// a new fetcher. // a new fetcher.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment