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

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2542853002: [tracing] Introduce config to setup memory-infra peak detection (Closed)
Patch Set: Fixes. 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/allocator/features.h" 10 #include "base/allocator/features.h"
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 // At the moment the periodic support is limited to at most one periodic 835 // At the moment the periodic support is limited to at most one periodic
836 // trigger per dump mode. All intervals should be an integer multiple of the 836 // trigger per dump mode. All intervals should be an integer multiple of the
837 // smallest interval specified. 837 // smallest interval specified.
838 periodic_dumps_count_ = 0; 838 periodic_dumps_count_ = 0;
839 uint32_t min_timer_period_ms = std::numeric_limits<uint32_t>::max(); 839 uint32_t min_timer_period_ms = std::numeric_limits<uint32_t>::max();
840 uint32_t light_dump_period_ms = 0; 840 uint32_t light_dump_period_ms = 0;
841 uint32_t heavy_dump_period_ms = 0; 841 uint32_t heavy_dump_period_ms = 0;
842 DCHECK_LE(triggers_list.size(), 3u); 842 DCHECK_LE(triggers_list.size(), 3u);
843 auto* mdm = MemoryDumpManager::GetInstance(); 843 auto* mdm = MemoryDumpManager::GetInstance();
844 for (const TraceConfig::MemoryDumpConfig::Trigger& config : triggers_list) { 844 for (const TraceConfig::MemoryDumpConfig::Trigger& config : triggers_list) {
845 DCHECK_NE(0u, config.periodic_interval_ms); 845 DCHECK_NE(0u, config.min_time_between_dumps_ms);
846 DCHECK_EQ(MemoryDumpType::PERIODIC_INTERVAL, config.trigger_type)
Primiano Tucci (use gerrit) 2016/12/16 12:13:55 just double checking, this is something that will
ssid 2016/12/16 19:19:52 yes this will be removed in next cls.
847 << "Only periodic_interval triggers are suppported";
846 switch (config.level_of_detail) { 848 switch (config.level_of_detail) {
847 case MemoryDumpLevelOfDetail::BACKGROUND: 849 case MemoryDumpLevelOfDetail::BACKGROUND:
848 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::BACKGROUND)); 850 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::BACKGROUND));
849 break; 851 break;
850 case MemoryDumpLevelOfDetail::LIGHT: 852 case MemoryDumpLevelOfDetail::LIGHT:
851 DCHECK_EQ(0u, light_dump_period_ms); 853 DCHECK_EQ(0u, light_dump_period_ms);
852 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::LIGHT)); 854 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::LIGHT));
853 light_dump_period_ms = config.periodic_interval_ms; 855 light_dump_period_ms = config.min_time_between_dumps_ms;
854 break; 856 break;
855 case MemoryDumpLevelOfDetail::DETAILED: 857 case MemoryDumpLevelOfDetail::DETAILED:
856 DCHECK_EQ(0u, heavy_dump_period_ms); 858 DCHECK_EQ(0u, heavy_dump_period_ms);
857 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::DETAILED)); 859 DCHECK(mdm->IsDumpModeAllowed(MemoryDumpLevelOfDetail::DETAILED));
858 heavy_dump_period_ms = config.periodic_interval_ms; 860 heavy_dump_period_ms = config.min_time_between_dumps_ms;
859 break; 861 break;
860 } 862 }
861 min_timer_period_ms = 863 min_timer_period_ms =
862 std::min(min_timer_period_ms, config.periodic_interval_ms); 864 std::min(min_timer_period_ms, config.min_time_between_dumps_ms);
863 } 865 }
864 866
865 DCHECK_EQ(0u, light_dump_period_ms % min_timer_period_ms); 867 DCHECK_EQ(0u, light_dump_period_ms % min_timer_period_ms);
866 light_dump_rate_ = light_dump_period_ms / min_timer_period_ms; 868 light_dump_rate_ = light_dump_period_ms / min_timer_period_ms;
867 DCHECK_EQ(0u, heavy_dump_period_ms % min_timer_period_ms); 869 DCHECK_EQ(0u, heavy_dump_period_ms % min_timer_period_ms);
868 heavy_dump_rate_ = heavy_dump_period_ms / min_timer_period_ms; 870 heavy_dump_rate_ = heavy_dump_period_ms / min_timer_period_ms;
869 871
870 timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(min_timer_period_ms), 872 timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(min_timer_period_ms),
871 base::Bind(&PeriodicGlobalDumpTimer::RequestPeriodicGlobalDump, 873 base::Bind(&PeriodicGlobalDumpTimer::RequestPeriodicGlobalDump,
872 base::Unretained(this))); 874 base::Unretained(this)));
(...skipping 16 matching lines...) Expand all
889 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) 891 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0)
890 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; 892 level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
891 ++periodic_dumps_count_; 893 ++periodic_dumps_count_;
892 894
893 MemoryDumpManager::GetInstance()->RequestGlobalDump( 895 MemoryDumpManager::GetInstance()->RequestGlobalDump(
894 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); 896 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
895 } 897 }
896 898
897 } // namespace trace_event 899 } // namespace trace_event
898 } // namespace base 900 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_request_args.h » ('j') | base/trace_event/trace_config_memory_test_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698