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

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

Issue 1152743003: Making the MemoryDumpManager less aggressive in disabling dump providers on failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 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 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // straight away (FinalizeDumpAndAddToTrace() takes care of the callback). 310 // straight away (FinalizeDumpAndAddToTrace() takes care of the callback).
311 if (did_any_provider_dump && pmd_holder->num_pending_async_requests == 0) 311 if (did_any_provider_dump && pmd_holder->num_pending_async_requests == 0)
312 FinalizeDumpAndAddToTrace(pmd_holder); 312 FinalizeDumpAndAddToTrace(pmd_holder);
313 } 313 }
314 314
315 // Invokes the MemoryDumpProvider.OnMemoryDump(), taking care of the fail-safe 315 // Invokes the MemoryDumpProvider.OnMemoryDump(), taking care of the fail-safe
316 // logic which disables the dumper when failing (crbug.com/461788). 316 // logic which disables the dumper when failing (crbug.com/461788).
317 bool MemoryDumpManager::InvokeDumpProviderLocked(MemoryDumpProvider* mdp, 317 bool MemoryDumpManager::InvokeDumpProviderLocked(MemoryDumpProvider* mdp,
318 ProcessMemoryDump* pmd) { 318 ProcessMemoryDump* pmd) {
319 lock_.AssertAcquired(); 319 lock_.AssertAcquired();
320 const int kMaxFailuresCount = 3;
Primiano Tucci (use gerrit) 2015/06/10 23:37:07 +consecutive
ssid 2015/06/12 14:37:00 Done.
320 bool dump_successful = mdp->OnMemoryDump(pmd); 321 bool dump_successful = mdp->OnMemoryDump(pmd);
321 if (!dump_successful) { 322 if (!dump_successful) {
322 LOG(ERROR) << "The memory dumper failed, possibly due to sandboxing " 323 LOG(ERROR) << "The memory dumper failed, possibly due to sandboxing "
Primiano Tucci (use gerrit) 2015/06/10 23:37:07 you want to give this message only if it fails N t
ssid 2015/06/12 14:37:00 Done.
323 "(crbug.com/461788), disabling it for current process. Try " 324 "(crbug.com/461788), disabling it for current process. Try "
324 "restarting chrome with the --no-sandbox switch."; 325 "restarting chrome with the --no-sandbox switch.";
325 dump_providers_.find(mdp)->second.disabled = true; 326
327 // Disable the MDP if it fails kMaxFailuresCount times consecutively.
328 dump_providers_.find(mdp)->second.failures++;
Primiano Tucci (use gerrit) 2015/06/10 23:37:07 Let's just lookup once, and keep the ptr to the md
ssid 2015/06/12 14:37:00 Done.
329 if (dump_providers_.find(mdp)->second.failures >= kMaxFailuresCount)
330 dump_providers_.find(mdp)->second.disabled = true;
331 } else {
332 dump_providers_.find(mdp)->second.failures = 0;
326 } 333 }
327 return dump_successful; 334 return dump_successful;
328 } 335 }
329 336
330 // This is posted to arbitrary threads as a continuation of CreateProcessDump(), 337 // This is posted to arbitrary threads as a continuation of CreateProcessDump(),
331 // when one or more MemoryDumpProvider(s) require the OnMemoryDump() call to 338 // when one or more MemoryDumpProvider(s) require the OnMemoryDump() call to
332 // happen on a different thread. 339 // happen on a different thread.
333 void MemoryDumpManager::ContinueAsyncProcessDump( 340 void MemoryDumpManager::ContinueAsyncProcessDump(
334 MemoryDumpProvider* mdp, 341 MemoryDumpProvider* mdp,
335 scoped_refptr<ProcessMemoryDumpHolder> pmd_holder) { 342 scoped_refptr<ProcessMemoryDumpHolder> pmd_holder) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // There is no point starting the tracing without a delegate. 376 // There is no point starting the tracing without a delegate.
370 if (!enabled || !delegate_) { 377 if (!enabled || !delegate_) {
371 // Disable all the providers. 378 // Disable all the providers.
372 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) 379 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it)
373 it->second.disabled = true; 380 it->second.disabled = true;
374 return; 381 return;
375 } 382 }
376 383
377 session_state_ = new MemoryDumpSessionState(); 384 session_state_ = new MemoryDumpSessionState();
378 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) 385 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it)
379 it->second.disabled = false; 386 it->second.disabled = false;
Primiano Tucci (use gerrit) 2015/06/10 23:37:07 and you want to reset the count here, otherwise on
ssid 2015/06/12 14:37:00 Done.
380 387
381 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); 388 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1);
382 389
383 if (delegate_->IsCoordinatorProcess()) { 390 if (delegate_->IsCoordinatorProcess()) {
384 periodic_dump_timer_.Start(FROM_HERE, 391 periodic_dump_timer_.Start(FROM_HERE,
385 TimeDelta::FromSeconds(kDumpIntervalSeconds), 392 TimeDelta::FromSeconds(kDumpIntervalSeconds),
386 base::Bind(&RequestPeriodicGlobalDump)); 393 base::Bind(&RequestPeriodicGlobalDump));
387 } 394 }
388 } 395 }
389 396
390 void MemoryDumpManager::OnTraceLogDisabled() { 397 void MemoryDumpManager::OnTraceLogDisabled() {
391 AutoLock lock(lock_); 398 AutoLock lock(lock_);
392 periodic_dump_timer_.Stop(); 399 periodic_dump_timer_.Stop();
393 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); 400 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
394 session_state_ = nullptr; 401 session_state_ = nullptr;
395 } 402 }
396 403
397 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( 404 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo(
398 const scoped_refptr<SingleThreadTaskRunner>& task_runner) 405 const scoped_refptr<SingleThreadTaskRunner>& task_runner)
399 : task_runner(task_runner), disabled(false) { 406 : task_runner(task_runner), failures(0), disabled(false) {
400 } 407 }
401 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { 408 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() {
402 } 409 }
403 410
404 } // namespace trace_event 411 } // namespace trace_event
405 } // namespace base 412 } // namespace base
OLDNEW
« base/trace_event/memory_dump_manager.h ('K') | « base/trace_event/memory_dump_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698