Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: components/startup_metric_utils/browser/startup_metric_utils.cc

Issue 2530043002: Set process phases in the StackSamplingProfiler. (Closed)
Patch Set: addressed review comments by wittman Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/startup_metric_utils/browser/DEPS ('k') | content/browser/browser_main_loop.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/startup_metric_utils/browser/startup_metric_utils.h" 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
18 #include "base/process/process_info.h" 18 #include "base/process/process_info.h"
19 #include "base/profiler/stack_sampling_profiler.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/sys_info.h" 21 #include "base/sys_info.h"
21 #include "base/threading/platform_thread.h" 22 #include "base/threading/platform_thread.h"
22 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "components/metrics/call_stack_profile_metrics_provider.h"
24 #include "components/prefs/pref_registry_simple.h" 26 #include "components/prefs/pref_registry_simple.h"
25 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
26 #include "components/startup_metric_utils/browser/pref_names.h" 28 #include "components/startup_metric_utils/browser/pref_names.h"
27 #include "components/version_info/version_info.h" 29 #include "components/version_info/version_info.h"
28 30
29 #if defined(OS_WIN) 31 #if defined(OS_WIN)
30 #include <winternl.h> 32 #include <winternl.h>
31 #include "base/win/win_util.h" 33 #include "base/win/win_util.h"
32 #endif 34 #endif
33 35
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 596
595 RecordSameVersionStartupCount(pref_service); 597 RecordSameVersionStartupCount(pref_service);
596 // Keep RecordHardFaultHistogram() first as much as possible as many other 598 // Keep RecordHardFaultHistogram() first as much as possible as many other
597 // histograms depend on it setting |g_startup_temperature|. 599 // histograms depend on it setting |g_startup_temperature|.
598 RecordHardFaultHistogram(); 600 RecordHardFaultHistogram();
599 AddStartupEventsForTelemetry(); 601 AddStartupEventsForTelemetry();
600 RecordTimeSinceLastStartup(pref_service); 602 RecordTimeSinceLastStartup(pref_service);
601 RecordSystemUptimeHistogram(); 603 RecordSystemUptimeHistogram();
602 RecordMainEntryTimeHistogram(); 604 RecordMainEntryTimeHistogram();
603 605
606 base::StackSamplingProfiler::SetProcessPhase(
607 metrics::CallStackProfileMetricsProvider::MAIN_LOOP_START);
Mike Wittman 2016/12/01 18:46:50 This line should be as close as possible to where
Alexei Svitkine (slow) 2016/12/01 19:49:12 Right, I think we need to clearly define what SetP
Alexei Svitkine (slow) 2017/01/05 20:54:12 Ping on this comment.
bcwhite 2017/01/06 16:50:56 In this case, the name indicates that the "main lo
Alexei Svitkine (slow) 2017/01/09 19:12:18 I guess I'm less concerned with the name and more
bcwhite 2017/01/10 17:56:54 That's not what it does, though. Perhaps "SetProc
Mike Wittman 2017/01/10 20:10:36 Just noticed that this comment still remains to be
bcwhite 2017/01/11 16:15:48 If I understand you correctly, this amounts to rem
Mike Wittman 2017/01/11 16:24:47 Yes, and moving the histogram recording immediatel
bcwhite 2017/01/11 16:26:39 Looking further, every other method also takes a t
Mike Wittman 2017/01/11 16:30:18 Sounds good to me.
bcwhite 2017/01/11 16:53:28 Done (order) and Done (naming).
608
604 const base::TimeTicks& process_creation_ticks = 609 const base::TimeTicks& process_creation_ticks =
605 g_process_creation_ticks.Get(); 610 g_process_creation_ticks.Get();
606 if (!is_first_run && !process_creation_ticks.is_null()) { 611 if (!is_first_run && !process_creation_ticks.is_null()) {
607 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 612 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
608 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", 613 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime",
609 process_creation_ticks, ticks); 614 process_creation_ticks, ticks);
610 } 615 }
611 616
612 // TODO(fdoray): Remove histograms that are only recorded after 7 minutes of 617 // TODO(fdoray): Remove histograms that are only recorded after 7 minutes of
613 // OS uptime once M54 hits stable. These histograms are kept for now to allow 618 // OS uptime once M54 hits stable. These histograms are kept for now to allow
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return; 734 return;
730 is_first_call = false; 735 is_first_call = false;
731 736
732 // Log Startup.BrowserMainToRendererMain now that the first renderer main 737 // Log Startup.BrowserMainToRendererMain now that the first renderer main
733 // entry time and the startup temperature are known. 738 // entry time and the startup temperature are known.
734 RecordRendererMainEntryHistogram(); 739 RecordRendererMainEntryHistogram();
735 740
736 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) 741 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
737 return; 742 return;
738 743
744 base::StackSamplingProfiler::SetProcessPhase(
745 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT);
739 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 746 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
740 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", 747 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2",
741 g_process_creation_ticks.Get(), ticks); 748 g_process_creation_ticks.Get(), ticks);
742 } 749 }
743 750
744 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) { 751 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) {
745 static bool is_first_call = true; 752 static bool is_first_call = true;
746 if (!is_first_call || ticks.is_null()) 753 if (!is_first_call || ticks.is_null())
747 return; 754 return;
748 is_first_call = false; 755 is_first_call = false;
749 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) 756 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
750 return; 757 return;
751 758
759 base::StackSamplingProfiler::SetProcessPhase(
760 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START);
752 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 761 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
753 UMA_HISTOGRAM_LONG_TIMES_100, 762 UMA_HISTOGRAM_LONG_TIMES_100,
754 "Startup.FirstWebContents.MainNavigationStart", 763 "Startup.FirstWebContents.MainNavigationStart",
755 g_process_creation_ticks.Get(), ticks); 764 g_process_creation_ticks.Get(), ticks);
756 } 765 }
757 766
758 void RecordFirstWebContentsMainNavigationFinished( 767 void RecordFirstWebContentsMainNavigationFinished(
759 const base::TimeTicks& ticks) { 768 const base::TimeTicks& ticks) {
760 static bool is_first_call = true; 769 static bool is_first_call = true;
761 if (!is_first_call || ticks.is_null()) 770 if (!is_first_call || ticks.is_null())
762 return; 771 return;
763 is_first_call = false; 772 is_first_call = false;
764 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) 773 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
765 return; 774 return;
766 775
776 base::StackSamplingProfiler::SetProcessPhase(
777 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_FINISHED);
767 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 778 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
768 UMA_HISTOGRAM_LONG_TIMES_100, 779 UMA_HISTOGRAM_LONG_TIMES_100,
769 "Startup.FirstWebContents.MainNavigationFinished", 780 "Startup.FirstWebContents.MainNavigationFinished",
770 g_process_creation_ticks.Get(), ticks); 781 g_process_creation_ticks.Get(), ticks);
771 } 782 }
772 783
773 base::TimeTicks MainEntryPointTicks() { 784 base::TimeTicks MainEntryPointTicks() {
774 return g_browser_main_entry_point_ticks.Get(); 785 return g_browser_main_entry_point_ticks.Get();
775 } 786 }
776 787
777 } // namespace startup_metric_utils 788 } // namespace startup_metric_utils
OLDNEW
« no previous file with comments | « components/startup_metric_utils/browser/DEPS ('k') | content/browser/browser_main_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698