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

Side by Side Diff: net/spdy/spdy_session_pool.cc

Issue 2665283003: Improve memory estimate of SpdySessionPool in net/ MemoryDumpProvider. (Closed)
Patch Set: address bnc comments Created 3 years, 10 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 (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/spdy/spdy_session_pool.h" 5 #include "net/spdy/spdy_session_pool.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/profiler/scoped_tracker.h" 12 #include "base/profiler/scoped_tracker.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/trace_event/memory_allocator_dump.h" 15 #include "base/trace_event/memory_allocator_dump.h"
16 #include "base/trace_event/memory_usage_estimator.h"
16 #include "base/trace_event/process_memory_dump.h" 17 #include "base/trace_event/process_memory_dump.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "net/base/address_list.h" 20 #include "net/base/address_list.h"
20 #include "net/base/trace_constants.h" 21 #include "net/base/trace_constants.h"
21 #include "net/http/http_network_session.h" 22 #include "net/http/http_network_session.h"
22 #include "net/http/http_server_properties.h" 23 #include "net/http/http_server_properties.h"
23 #include "net/log/net_log_event_type.h" 24 #include "net/log/net_log_event_type.h"
24 #include "net/log/net_log_source.h" 25 #include "net/log/net_log_source.h"
25 #include "net/log/net_log_with_source.h" 26 #include "net/log/net_log_with_source.h"
27 #include "net/spdy/hpack/hpack_constants.h"
28 #include "net/spdy/hpack/hpack_huffman_table.h"
29 #include "net/spdy/hpack/hpack_static_table.h"
26 #include "net/spdy/spdy_session.h" 30 #include "net/spdy/spdy_session.h"
27 31
28 namespace net { 32 namespace net {
29 33
30 namespace { 34 namespace {
31 35
32 enum SpdySessionGetTypes { 36 enum SpdySessionGetTypes {
33 CREATED_NEW = 0, 37 CREATED_NEW = 0,
34 FOUND_EXISTING = 1, 38 FOUND_EXISTING = 1,
35 FOUND_EXISTING_FROM_IP_POOL = 2, 39 FOUND_EXISTING_FROM_IP_POOL = 2,
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (sessions_.empty()) 378 if (sessions_.empty())
375 return; 379 return;
376 size_t total_size = 0; 380 size_t total_size = 0;
377 size_t buffer_size = 0; 381 size_t buffer_size = 0;
378 size_t cert_count = 0; 382 size_t cert_count = 0;
379 size_t serialized_cert_size = 0; 383 size_t serialized_cert_size = 0;
380 size_t num_active_sessions = 0; 384 size_t num_active_sessions = 0;
381 for (const auto& session : sessions_) { 385 for (const auto& session : sessions_) {
382 StreamSocket::SocketMemoryStats stats; 386 StreamSocket::SocketMemoryStats stats;
383 bool is_session_active = false; 387 bool is_session_active = false;
384 session->DumpMemoryStats(&stats, &is_session_active); 388 total_size += session->DumpMemoryStats(&stats, &is_session_active);
385 total_size += stats.total_size;
386 buffer_size += stats.buffer_size; 389 buffer_size += stats.buffer_size;
387 cert_count += stats.cert_count; 390 cert_count += stats.cert_count;
388 serialized_cert_size += stats.serialized_cert_size; 391 serialized_cert_size += stats.serialized_cert_size;
389 if (is_session_active) 392 if (is_session_active)
390 num_active_sessions++; 393 num_active_sessions++;
391 } 394 }
395 total_size +=
396 base::trace_event::EstimateMemoryUsage(ObtainHpackHuffmanTable()) +
397 base::trace_event::EstimateMemoryUsage(ObtainHpackStaticTable());
392 base::trace_event::MemoryAllocatorDump* dump = 398 base::trace_event::MemoryAllocatorDump* dump =
393 pmd->CreateAllocatorDump(base::StringPrintf( 399 pmd->CreateAllocatorDump(base::StringPrintf(
394 "%s/spdy_session_pool", parent_dump_absolute_name.c_str())); 400 "%s/spdy_session_pool", parent_dump_absolute_name.c_str()));
395 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 401 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
396 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 402 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
397 total_size); 403 total_size);
398 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, 404 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount,
399 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 405 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
400 sessions_.size()); 406 sessions_.size());
401 dump->AddScalar("active_session_count", 407 dump->AddScalar("active_session_count",
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 484
479 if (idle_only && (*it)->is_active()) 485 if (idle_only && (*it)->is_active())
480 continue; 486 continue;
481 487
482 (*it)->CloseSessionOnError(error, description); 488 (*it)->CloseSessionOnError(error, description);
483 DCHECK(!IsSessionAvailable(*it)); 489 DCHECK(!IsSessionAvailable(*it));
484 } 490 }
485 } 491 }
486 492
487 } // namespace net 493 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698