forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tracing] Adding Skia memory dump provider with cache totals
This CL adds a dump provider to dump skia memory statistics to chrome://tracing. The dump provider dumps only the totals of SkGlyphCache and SkResourceCache. BUG=503168 Review URL: https://codereview.chromium.org/1253403002 Cr-Commit-Position: refs/heads/master@{#340674}
- Loading branch information
1 parent
574c7ea
commit 59c9691
Showing
8 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "skia_memory_dump_provider.h" | ||
|
||
#include "base/trace_event/memory_allocator_dump.h" | ||
#include "base/trace_event/memory_dump_manager.h" | ||
#include "base/trace_event/process_memory_dump.h" | ||
#include "third_party/skia/include/core/SkGraphics.h" | ||
#include "third_party/skia/src/core/SkResourceCache.h" | ||
|
||
namespace skia { | ||
|
||
// static | ||
SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() { | ||
return Singleton<SkiaMemoryDumpProvider, | ||
LeakySingletonTraits<SkiaMemoryDumpProvider>>::get(); | ||
} | ||
|
||
SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {} | ||
|
||
SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {} | ||
|
||
bool SkiaMemoryDumpProvider::OnMemoryDump( | ||
base::trace_event::ProcessMemoryDump* process_memory_dump) { | ||
auto font_mad = | ||
process_memory_dump->CreateAllocatorDump("skia/sk_font_cache"); | ||
font_mad->AddScalar("size", "bytes", SkGraphics::GetFontCacheUsed()); | ||
font_mad->AddScalar("count", "objects", SkGraphics::GetFontCacheCountUsed()); | ||
|
||
auto resource_mad = | ||
process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache"); | ||
resource_mad->AddScalar("size", "bytes", | ||
SkResourceCache::GetTotalBytesUsed()); | ||
// TODO(ssid): crbug.com/503168. Add sub-allocation edges from discardable or | ||
// malloc memory dumps to avoid double counting. | ||
|
||
return true; | ||
} | ||
|
||
} // namespace skia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef SKIA_EXT_SKIA_MEMORY_DUMP_PROVIDER_H_ | ||
#define SKIA_EXT_SKIA_MEMORY_DUMP_PROVIDER_H_ | ||
|
||
#include "base/memory/singleton.h" | ||
#include "base/trace_event/memory_dump_provider.h" | ||
#include "third_party/skia/include/core/SkTypes.h" | ||
|
||
namespace skia { | ||
|
||
class SK_API SkiaMemoryDumpProvider | ||
: public base::trace_event::MemoryDumpProvider { | ||
public: | ||
static SkiaMemoryDumpProvider* GetInstance(); | ||
|
||
// base::trace_event::MemoryDumpProvider implementation: | ||
bool OnMemoryDump( | ||
base::trace_event::ProcessMemoryDump* process_memory_dump) override; | ||
|
||
private: | ||
friend struct DefaultSingletonTraits<SkiaMemoryDumpProvider>; | ||
|
||
SkiaMemoryDumpProvider(); | ||
~SkiaMemoryDumpProvider() override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(SkiaMemoryDumpProvider); | ||
}; | ||
|
||
} // namespace skia | ||
|
||
#endif // SKIA_EXT_SKIA_MEMORY_DUMP_PROVIDER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/trace_event/process_memory_dump.h" | ||
#include "skia/ext/skia_memory_dump_provider.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace skia { | ||
|
||
TEST(SkiaMemoryDumpProviderTest, OnMemoryDump) { | ||
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( | ||
new base::trace_event::ProcessMemoryDump(nullptr)); | ||
SkiaMemoryDumpProvider::GetInstance()->OnMemoryDump( | ||
process_memory_dump.get()); | ||
|
||
ASSERT_TRUE(process_memory_dump->GetAllocatorDump("skia/sk_font_cache")); | ||
ASSERT_TRUE(process_memory_dump->GetAllocatorDump("skia/sk_resource_cache")); | ||
} | ||
|
||
} // namespace skia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters