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

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

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

Powered by Google App Engine
This is Rietveld 408576698