Index: net/ssl/ssl_client_session_cache.cc |
diff --git a/net/ssl/ssl_client_session_cache.cc b/net/ssl/ssl_client_session_cache.cc |
index b007469b9a9eba3c0c59e9651c622f854ae2ce8c..0eac4c9f9bff7d82a8350080ced576f8954d3edd 100644 |
--- a/net/ssl/ssl_client_session_cache.cc |
+++ b/net/ssl/ssl_client_session_cache.cc |
@@ -4,6 +4,7 @@ |
#include "net/ssl/ssl_client_session_cache.h" |
+#include <unordered_set> |
#include <utility> |
#include "base/memory/memory_coordinator_client_registry.h" |
@@ -122,29 +123,42 @@ void SSLClientSessionCache::DumpMemoryStats( |
return; |
cache_dump = pmd->CreateAllocatorDump(absolute_name); |
base::AutoLock lock(lock_); |
- size_t total_serialized_cert_size = 0; |
+ size_t total_cert_size = 0; |
+ size_t undeduped_cert_size = 0; |
size_t total_cert_count = 0; |
+ std::unordered_set<const CRYPTO_BUFFER*> crypto_buffer_set; |
DmitrySkiba
2017/02/17 22:02:58
I'm worried that this will slow things down. We've
davidben
2017/02/17 22:09:46
In the session cache, I would expect it to not do
xunjieli
2017/02/17 22:22:01
I don't think we can know the factor of total numb
|
for (const auto& pair : cache_) { |
const SSL_SESSION* session = pair.second.session.get(); |
size_t cert_count = sk_CRYPTO_BUFFER_num(session->certs); |
total_cert_count += cert_count; |
for (size_t i = 0; i < cert_count; ++i) { |
const CRYPTO_BUFFER* cert = sk_CRYPTO_BUFFER_value(session->certs, i); |
- total_serialized_cert_size += CRYPTO_BUFFER_len(cert); |
+ // TODO(xunjieli): The multipler is added to account for the difference |
+ // between the serialized form and real cert allocation. Remove after |
+ // crbug.com/671420 is done. |
+ size_t cert_size = 4 * CRYPTO_BUFFER_len(cert); |
+ undeduped_cert_size += cert_size; |
+ if (crypto_buffer_set.find(cert) != crypto_buffer_set.end()) |
+ continue; |
+ total_cert_size += cert_size; |
+ crypto_buffer_set.insert(cert); |
} |
} |
// This measures the lower bound of the serialized certificate. It doesn't |
// measure the actual memory used, which is 4x this amount (see |
// crbug.com/671420 for more details). |
- cache_dump->AddScalar("serialized_cert_size", |
+ cache_dump->AddScalar("cert_size", |
base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
- total_serialized_cert_size); |
+ total_cert_size); |
+ cache_dump->AddScalar("undeduped_cert_size", |
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
+ undeduped_cert_size); |
cache_dump->AddScalar("cert_count", |
base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
total_cert_count); |
cache_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
- total_serialized_cert_size); |
+ total_cert_size); |
} |
SSLClientSessionCache::Entry::Entry() : lookups(0) {} |