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

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 final review comments Created 3 years, 11 months 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null()); 587 DCHECK(g_browser_exe_main_entry_point_ticks.Get().is_null());
586 g_browser_exe_main_entry_point_ticks.Get() = ticks; 588 g_browser_exe_main_entry_point_ticks.Get() = ticks;
587 DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null()); 589 DCHECK(!g_browser_exe_main_entry_point_ticks.Get().is_null());
588 } 590 }
589 591
590 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, 592 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
591 bool is_first_run, 593 bool is_first_run,
592 PrefService* pref_service) { 594 PrefService* pref_service) {
593 DCHECK(pref_service); 595 DCHECK(pref_service);
594 596
597 // Keep RecordSameVersionStartupCount() and RecordHardFaultHistogram() near
598 // the top of this method (as much as possible) as many other histograms
599 // depend on it setting |g_startup_temperature|.
fdoray 2017/01/12 17:59:36 on them setting |g_startup_temperature| and |g_sta
bcwhite 2017/01/12 18:25:25 Done.
595 RecordSameVersionStartupCount(pref_service); 600 RecordSameVersionStartupCount(pref_service);
596 // Keep RecordHardFaultHistogram() first as much as possible as many other
597 // histograms depend on it setting |g_startup_temperature|.
598 RecordHardFaultHistogram(); 601 RecordHardFaultHistogram();
599 AddStartupEventsForTelemetry();
600 RecordTimeSinceLastStartup(pref_service);
601 RecordSystemUptimeHistogram();
602 RecordMainEntryTimeHistogram();
603 602
603 // Record timing of the browser message-loop start time.
604 base::StackSamplingProfiler::SetProcessMilestone(
605 metrics::CallStackProfileMetricsProvider::MAIN_LOOP_START);
604 const base::TimeTicks& process_creation_ticks = 606 const base::TimeTicks& process_creation_ticks =
605 g_process_creation_ticks.Get(); 607 g_process_creation_ticks.Get();
606 if (!is_first_run && !process_creation_ticks.is_null()) { 608 if (!is_first_run && !process_creation_ticks.is_null()) {
607 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 609 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
608 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime", 610 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.BrowserMessageLoopStartTime",
609 process_creation_ticks, ticks); 611 process_creation_ticks, ticks);
610 } 612 }
611 613
612 // Record timing between the shared library's main() entry and the browser 614 // Record timing between the shared library's main() entry and the browser
613 // main message loop start. 615 // main message loop start.
614 if (is_first_run) { 616 if (is_first_run) {
615 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE( 617 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE(
616 UMA_HISTOGRAM_LONG_TIMES, 618 UMA_HISTOGRAM_LONG_TIMES,
617 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun2", 619 "Startup.BrowserMessageLoopStartTimeFromMainEntry.FirstRun2",
618 g_browser_main_entry_point_ticks.Get(), ticks); 620 g_browser_main_entry_point_ticks.Get(), ticks);
619 } else { 621 } else {
620 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 622 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
621 UMA_HISTOGRAM_LONG_TIMES, 623 UMA_HISTOGRAM_LONG_TIMES,
622 "Startup.BrowserMessageLoopStartTimeFromMainEntry2", 624 "Startup.BrowserMessageLoopStartTimeFromMainEntry2",
623 g_browser_main_entry_point_ticks.Get(), ticks); 625 g_browser_main_entry_point_ticks.Get(), ticks);
624 } 626 }
625 627
628 AddStartupEventsForTelemetry();
629 RecordTimeSinceLastStartup(pref_service);
630 RecordSystemUptimeHistogram();
631 RecordMainEntryTimeHistogram();
632
626 // Record timings between process creation, the main() in the executable being 633 // Record timings between process creation, the main() in the executable being
627 // reached and the main() in the shared library being reached. 634 // reached and the main() in the shared library being reached.
628 if (!process_creation_ticks.is_null() && 635 if (!process_creation_ticks.is_null() &&
629 !g_browser_exe_main_entry_point_ticks.Get().is_null()) { 636 !g_browser_exe_main_entry_point_ticks.Get().is_null()) {
630 const base::TimeTicks exe_main_ticks = 637 const base::TimeTicks exe_main_ticks =
631 g_browser_exe_main_entry_point_ticks.Get(); 638 g_browser_exe_main_entry_point_ticks.Get();
632 const base::TimeTicks main_entry_ticks = 639 const base::TimeTicks main_entry_ticks =
633 g_browser_main_entry_point_ticks.Get(); 640 g_browser_main_entry_point_ticks.Get();
634 // Process create to chrome.exe:main(). 641 // Process create to chrome.exe:main().
635 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 642 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 return; 705 return;
699 is_first_call = false; 706 is_first_call = false;
700 707
701 // Log Startup.BrowserMainToRendererMain now that the first renderer main 708 // Log Startup.BrowserMainToRendererMain now that the first renderer main
702 // entry time and the startup temperature are known. 709 // entry time and the startup temperature are known.
703 RecordRendererMainEntryHistogram(); 710 RecordRendererMainEntryHistogram();
704 711
705 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) 712 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
706 return; 713 return;
707 714
715 base::StackSamplingProfiler::SetProcessMilestone(
716 metrics::CallStackProfileMetricsProvider::FIRST_NONEMPTY_PAINT);
708 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 717 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
709 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2", 718 UMA_HISTOGRAM_LONG_TIMES_100, "Startup.FirstWebContents.NonEmptyPaint2",
710 g_process_creation_ticks.Get(), ticks); 719 g_process_creation_ticks.Get(), ticks);
711 } 720 }
712 721
713 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) { 722 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks) {
714 static bool is_first_call = true; 723 static bool is_first_call = true;
715 if (!is_first_call || ticks.is_null()) 724 if (!is_first_call || ticks.is_null())
716 return; 725 return;
717 is_first_call = false; 726 is_first_call = false;
718 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) 727 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
719 return; 728 return;
720 729
730 base::StackSamplingProfiler::SetProcessMilestone(
731 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_START);
721 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 732 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
722 UMA_HISTOGRAM_LONG_TIMES_100, 733 UMA_HISTOGRAM_LONG_TIMES_100,
723 "Startup.FirstWebContents.MainNavigationStart", 734 "Startup.FirstWebContents.MainNavigationStart",
724 g_process_creation_ticks.Get(), ticks); 735 g_process_creation_ticks.Get(), ticks);
725 } 736 }
726 737
727 void RecordFirstWebContentsMainNavigationFinished( 738 void RecordFirstWebContentsMainNavigationFinished(
728 const base::TimeTicks& ticks) { 739 const base::TimeTicks& ticks) {
729 static bool is_first_call = true; 740 static bool is_first_call = true;
730 if (!is_first_call || ticks.is_null()) 741 if (!is_first_call || ticks.is_null())
731 return; 742 return;
732 is_first_call = false; 743 is_first_call = false;
733 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null()) 744 if (WasNonBrowserUIDisplayed() || g_process_creation_ticks.Get().is_null())
734 return; 745 return;
735 746
747 base::StackSamplingProfiler::SetProcessMilestone(
748 metrics::CallStackProfileMetricsProvider::MAIN_NAVIGATION_FINISHED);
736 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( 749 UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT(
737 UMA_HISTOGRAM_LONG_TIMES_100, 750 UMA_HISTOGRAM_LONG_TIMES_100,
738 "Startup.FirstWebContents.MainNavigationFinished", 751 "Startup.FirstWebContents.MainNavigationFinished",
739 g_process_creation_ticks.Get(), ticks); 752 g_process_creation_ticks.Get(), ticks);
740 } 753 }
741 754
742 base::TimeTicks MainEntryPointTicks() { 755 base::TimeTicks MainEntryPointTicks() {
743 return g_browser_main_entry_point_ticks.Get(); 756 return g_browser_main_entry_point_ticks.Get();
744 } 757 }
745 758
746 } // namespace startup_metric_utils 759 } // 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