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

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

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