Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 job_controller_set_.size() <= last_logged_job_controller_count_) { | 365 job_controller_set_.size() <= last_logged_job_controller_count_) { |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 last_logged_job_controller_count_ = job_controller_set_.size(); | 368 last_logged_job_controller_count_ = job_controller_set_.size(); |
| 369 | 369 |
| 370 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobController", | 370 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobController", |
| 371 job_controller_set_.size()); | 371 job_controller_set_.size()); |
| 372 | 372 |
| 373 int alt_job_count = 0; | 373 int alt_job_count = 0; |
| 374 int main_job_count = 0; | 374 int main_job_count = 0; |
| 375 int pending_request_count = 0; | 375 size_t num_controllers_with_request = 0; |
| 376 int preconnect_controller_count = 0; | 376 size_t num_controllers_for_preconnect = 0; |
| 377 for (const auto& job_controller : job_controller_set_) { | 377 for (const auto& job_controller : job_controller_set_) { |
| 378 DCHECK(job_controller->HasPendingAltJob() || | 378 DCHECK(job_controller->HasPendingAltJob() || |
| 379 job_controller->HasPendingMainJob()); | 379 job_controller->HasPendingMainJob()); |
| 380 // Additionally logs the states of the jobs if there are at least 500 | 380 // Additionally logs the states of the jobs if there are at least 500 |
| 381 // controllers, which suggests that there might be a leak. | 381 // controllers, which suggests that there might be a leak. |
| 382 if (job_controller_set_.size() >= 500) | 382 if (job_controller_set_.size() >= 500) |
| 383 job_controller->LogHistograms(); | 383 job_controller->LogHistograms(); |
| 384 // For a preconnect controller, it should have exactly the main job. | 384 // For a preconnect controller, it should have exactly the main job. |
| 385 if (job_controller->is_preconnect()) { | 385 if (job_controller->is_preconnect()) { |
| 386 preconnect_controller_count++; | 386 num_controllers_for_preconnect++; |
| 387 continue; | 387 continue; |
| 388 } | 388 } |
| 389 // For non-preconnects. | 389 // For non-preconnects. |
| 390 if (job_controller->HasPendingRequest()) | 390 if (job_controller->HasPendingRequest()) |
| 391 pending_request_count++; | 391 num_controllers_with_request++; |
| 392 if (job_controller->HasPendingAltJob()) | 392 if (job_controller->HasPendingAltJob()) |
| 393 alt_job_count++; | 393 alt_job_count++; |
| 394 if (job_controller->HasPendingMainJob()) | 394 if (job_controller->HasPendingMainJob()) |
| 395 main_job_count++; | 395 main_job_count++; |
| 396 } | 396 } |
| 397 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect", | 397 DCHECK_GE(job_controller_set_.size(), num_controllers_for_preconnect); |
|
xunjieli
2017/04/19 17:50:04
I think this is redundant -- we are only increment
Zhongyi Shi
2017/04/19 18:43:51
Alright, let's get rid of all those DCHECKs.
| |
| 398 preconnect_controller_count); | 398 UMA_HISTOGRAM_COUNTS_1M( |
| 399 "Net.JobControllerSet.CountOfJobController.Preconnect", | |
| 400 num_controllers_for_preconnect); | |
| 401 UMA_HISTOGRAM_COUNTS_1M( | |
| 402 "Net.JobControllerSet.CountOfJobController.NonPreconnect.PendingRequest", | |
| 403 num_controllers_with_request); | |
| 404 | |
| 405 DCHECK_GE(job_controller_set_.size() - num_controllers_for_preconnect, | |
| 406 num_controllers_with_request); | |
| 407 UMA_HISTOGRAM_COUNTS_1M( | |
| 408 "Net.JobControllerSet.CountOfJobController.NonPreconnect.RequestGone", | |
| 409 job_controller_set_.size() - num_controllers_for_preconnect - | |
| 410 num_controllers_with_request); | |
| 411 | |
| 399 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", | 412 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", |
| 400 alt_job_count); | 413 alt_job_count); |
| 401 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", | 414 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", |
| 402 main_job_count); | 415 main_job_count); |
| 403 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPendingRequest", | |
| 404 pending_request_count); | |
| 405 } | 416 } |
| 406 | 417 |
| 407 void HttpStreamFactoryImpl::DumpMemoryStats( | 418 void HttpStreamFactoryImpl::DumpMemoryStats( |
| 408 base::trace_event::ProcessMemoryDump* pmd, | 419 base::trace_event::ProcessMemoryDump* pmd, |
| 409 const std::string& parent_absolute_name) const { | 420 const std::string& parent_absolute_name) const { |
| 410 if (job_controller_set_.empty()) | 421 if (job_controller_set_.empty()) |
| 411 return; | 422 return; |
| 412 std::string name = | 423 std::string name = |
| 413 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); | 424 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); |
| 414 base::trace_event::MemoryAllocatorDump* factory_dump = | 425 base::trace_event::MemoryAllocatorDump* factory_dump = |
| 415 pmd->CreateAllocatorDump(name); | 426 pmd->CreateAllocatorDump(name); |
| 416 size_t alt_job_count = 0; | 427 size_t alt_job_count = 0; |
| 417 size_t main_job_count = 0; | 428 size_t main_job_count = 0; |
| 418 size_t preconnect_controller_count = 0; | 429 size_t num_controllers_for_preconnect = 0; |
| 419 for (const auto& it : job_controller_set_) { | 430 for (const auto& it : job_controller_set_) { |
| 420 // For a preconnect controller, it should have exactly the main job. | 431 // For a preconnect controller, it should have exactly the main job. |
| 421 if (it->is_preconnect()) { | 432 if (it->is_preconnect()) { |
| 422 preconnect_controller_count++; | 433 num_controllers_for_preconnect++; |
| 423 continue; | 434 continue; |
| 424 } | 435 } |
| 425 // For non-preconnects. | 436 // For non-preconnects. |
| 426 if (it->HasPendingAltJob()) | 437 if (it->HasPendingAltJob()) |
| 427 alt_job_count++; | 438 alt_job_count++; |
| 428 if (it->HasPendingMainJob()) | 439 if (it->HasPendingMainJob()) |
| 429 main_job_count++; | 440 main_job_count++; |
| 430 } | 441 } |
| 431 factory_dump->AddScalar( | 442 factory_dump->AddScalar( |
| 432 base::trace_event::MemoryAllocatorDump::kNameSize, | 443 base::trace_event::MemoryAllocatorDump::kNameSize, |
| 433 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 444 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 434 base::trace_event::EstimateMemoryUsage(job_controller_set_)); | 445 base::trace_event::EstimateMemoryUsage(job_controller_set_)); |
| 435 factory_dump->AddScalar( | 446 factory_dump->AddScalar( |
| 436 base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 447 base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 437 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 448 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 438 job_controller_set_.size()); | 449 job_controller_set_.size()); |
| 439 // The number of non-preconnect controllers with a pending alt job. | 450 // The number of non-preconnect controllers with a pending alt job. |
| 440 factory_dump->AddScalar("alt_job_count", | 451 factory_dump->AddScalar("alt_job_count", |
| 441 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 452 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 442 alt_job_count); | 453 alt_job_count); |
| 443 // The number of non-preconnect controllers with a pending main job. | 454 // The number of non-preconnect controllers with a pending main job. |
| 444 factory_dump->AddScalar("main_job_count", | 455 factory_dump->AddScalar("main_job_count", |
| 445 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 456 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 446 main_job_count); | 457 main_job_count); |
| 447 // The number of preconnect controllers. | 458 // The number of preconnect controllers. |
| 448 factory_dump->AddScalar("preconnect_count", | 459 factory_dump->AddScalar("preconnect_count", |
| 449 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 460 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 450 preconnect_controller_count); | 461 num_controllers_for_preconnect); |
| 451 } | 462 } |
| 452 | 463 |
| 453 } // namespace net | 464 } // namespace net |
| OLD | NEW |