Commit 9760aac7 authored by Benoît Lizé's avatar Benoît Lizé Committed by Commit Bot

blink/bindings: Report the original size of ParkableStrings.

The original size is the size without compression. This allows to see the
savings in memory-infra memory dumps.

Also add a trace event for the aging task.

Bug: 924164
Change-Id: I5cb2f968f8ec51d330b66fa211fde048bb5e2323
Reviewed-on: https://chromium-review.googlesource.com/c/1456657
Commit-Queue: Benoit L <lizeb@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629926}
parent 70665464
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/trace_event/memory_allocator_dump.h" #include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h" #include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h" #include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/memory_pressure_listener.h" #include "third_party/blink/renderer/platform/memory_pressure_listener.h"
...@@ -133,12 +134,14 @@ bool ParkableStringManager::OnMemoryDump( ...@@ -133,12 +134,14 @@ bool ParkableStringManager::OnMemoryDump(
base::trace_event::MemoryAllocatorDump* dump = base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump("parkable_strings"); pmd->CreateAllocatorDump("parkable_strings");
size_t original_size = 0;
size_t uncompressed_size = 0; size_t uncompressed_size = 0;
size_t compressed_size = 0; size_t compressed_size = 0;
size_t metadata_size = 0; size_t metadata_size = 0;
size_t overhead_size = 0; size_t overhead_size = 0;
for (ParkableStringImpl* str : unparked_strings_.Values()) { for (ParkableStringImpl* str : unparked_strings_.Values()) {
original_size += str->CharactersSizeInBytes();
uncompressed_size += str->CharactersSizeInBytes(); uncompressed_size += str->CharactersSizeInBytes();
metadata_size += sizeof(ParkableStringImpl); metadata_size += sizeof(ParkableStringImpl);
...@@ -147,6 +150,7 @@ bool ParkableStringManager::OnMemoryDump( ...@@ -147,6 +150,7 @@ bool ParkableStringManager::OnMemoryDump(
} }
for (ParkableStringImpl* str : parked_strings_) { for (ParkableStringImpl* str : parked_strings_) {
original_size += str->CharactersSizeInBytes();
compressed_size += str->compressed_size(); compressed_size += str->compressed_size();
metadata_size += sizeof(ParkableStringImpl); metadata_size += sizeof(ParkableStringImpl);
} }
...@@ -154,6 +158,7 @@ bool ParkableStringManager::OnMemoryDump( ...@@ -154,6 +158,7 @@ bool ParkableStringManager::OnMemoryDump(
size_t total_size = size_t total_size =
uncompressed_size + compressed_size + metadata_size + overhead_size; uncompressed_size + compressed_size + metadata_size + overhead_size;
dump->AddScalar("size", "bytes", total_size); dump->AddScalar("size", "bytes", total_size);
dump->AddScalar("original_size", "bytes", original_size);
dump->AddScalar("uncompressed_size", "bytes", uncompressed_size); dump->AddScalar("uncompressed_size", "bytes", uncompressed_size);
dump->AddScalar("compressed_size", "bytes", compressed_size); dump->AddScalar("compressed_size", "bytes", compressed_size);
dump->AddScalar("metadata_size", "bytes", metadata_size); dump->AddScalar("metadata_size", "bytes", metadata_size);
...@@ -320,6 +325,7 @@ void ParkableStringManager::AgeStringsAndPark() { ...@@ -320,6 +325,7 @@ void ParkableStringManager::AgeStringsAndPark() {
if (!base::FeatureList::IsEnabled(kCompressParkableStringsInForeground)) if (!base::FeatureList::IsEnabled(kCompressParkableStringsInForeground))
return; return;
TRACE_EVENT0("blink", "ParkableStringManager::AgeStringsAndPark");
has_pending_aging_task_ = false; has_pending_aging_task_ = false;
WTF::Vector<ParkableStringImpl*> unparked = WTF::Vector<ParkableStringImpl*> unparked =
......
...@@ -688,6 +688,10 @@ TEST_F(ParkableStringTest, ReportMemoryDump) { ...@@ -688,6 +688,10 @@ TEST_F(ParkableStringTest, ReportMemoryDump) {
pmd.GetAllocatorDump("parkable_strings"); pmd.GetAllocatorDump("parkable_strings");
ASSERT_NE(nullptr, dump); ASSERT_NE(nullptr, dump);
MemoryAllocatorDump::Entry original("original_size", "bytes",
2 * kSizeKb * 1000);
EXPECT_THAT(dump->entries(), Contains(Eq(ByRef(original))));
// |parkable1| is unparked. // |parkable1| is unparked.
MemoryAllocatorDump::Entry uncompressed("uncompressed_size", "bytes", MemoryAllocatorDump::Entry uncompressed("uncompressed_size", "bytes",
kSizeKb * 1000); kSizeKb * 1000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment