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

Unified Diff: base/trace_event/heap_profiler_heap_dump_writer.h

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Add 'version' field. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/heap_profiler_heap_dump_writer.h
diff --git a/base/trace_event/heap_profiler_heap_dump_writer.h b/base/trace_event/heap_profiler_heap_dump_writer.h
index 6e9d29de8782a1258ab70f01b61c106c7eb63661..04239165ff65cf9694fd58c218dca2cc80947c0c 100644
--- a/base/trace_event/heap_profiler_heap_dump_writer.h
+++ b/base/trace_event/heap_profiler_heap_dump_writer.h
@@ -8,105 +8,20 @@
#include <stddef.h>
#include <memory>
-#include <set>
#include "base/base_export.h"
-#include "base/containers/hash_tables.h"
-#include "base/macros.h"
-#include "base/trace_event/heap_profiler_allocation_context.h"
namespace base {
namespace trace_event {
+class AllocationRegister;
class MemoryDumpSessionState;
-class StackFrameDeduplicator;
class TracedValue;
-class TypeNameDeduplicator;
-// Aggregates |metrics_by_context|, recursively breaks down the heap, and
-// returns a traced value with an "entries" array that can be dumped in the
-// trace log, following the format described in https://goo.gl/KY7zVE. The
-// number of entries is kept reasonable because long tails are not included.
BASE_EXPORT std::unique_ptr<TracedValue> ExportHeapDump(
- const hash_map<AllocationContext, AllocationMetrics>& metrics_by_context,
+ const AllocationRegister& allocation_register,
const MemoryDumpSessionState& session_state);
-namespace internal {
-
-namespace {
-struct Bucket;
-}
-
-// An entry in the "entries" array as described in https://goo.gl/KY7zVE.
-struct BASE_EXPORT Entry {
- size_t size;
- size_t count;
-
- // References a backtrace in the stack frame deduplicator. -1 means empty
- // backtrace (the root of the tree).
- int stack_frame_id;
-
- // References a type name in the type name deduplicator. -1 indicates that
- // the size is the cumulative size for all types (the root of the tree).
- int type_id;
-};
-
-// Comparison operator to enable putting |Entry| in a |std::set|.
-BASE_EXPORT bool operator<(Entry lhs, Entry rhs);
-
-// Serializes entries to an "entries" array in a traced value.
-BASE_EXPORT std::unique_ptr<TracedValue> Serialize(const std::set<Entry>& dump);
-
-// Helper class to dump a snapshot of an |AllocationRegister| or other heap
-// bookkeeping structure into a |TracedValue|. This class is intended to be
-// used as a one-shot local instance on the stack.
-class BASE_EXPORT HeapDumpWriter {
- public:
- // The |stack_frame_deduplicator| and |type_name_deduplicator| are not owned.
- // The heap dump writer assumes exclusive access to them during the lifetime
- // of the dump writer. The heap dumps are broken down for allocations bigger
- // than |breakdown_threshold_bytes|.
- HeapDumpWriter(StackFrameDeduplicator* stack_frame_deduplicator,
- TypeNameDeduplicator* type_name_deduplicator,
- uint32_t breakdown_threshold_bytes);
-
- ~HeapDumpWriter();
-
- // Aggregates allocations to compute the total size of the heap, then breaks
- // down the heap recursively. This produces the values that should be dumped
- // in the "entries" array. The number of entries is kept reasonable because
- // long tails are not included. Use |Serialize| to convert to a traced value.
- const std::set<Entry>& Summarize(
- const hash_map<AllocationContext, AllocationMetrics>& metrics_by_context);
-
- private:
- // Inserts an |Entry| for |Bucket| into |entries_|. Returns false if the
- // entry was present before, true if it was not.
- bool AddEntryForBucket(const Bucket& bucket);
-
- // Recursively breaks down a bucket into smaller buckets and adds entries for
- // the buckets worth dumping to |entries_|.
- void BreakDown(const Bucket& bucket);
-
- // The collection of entries that is filled by |Summarize|.
- std::set<Entry> entries_;
-
- // Helper for generating the |stackFrames| dictionary. Not owned, must outlive
- // this heap dump writer instance.
- StackFrameDeduplicator* const stack_frame_deduplicator_;
-
- // Helper for converting type names to IDs. Not owned, must outlive this heap
- // dump writer instance.
- TypeNameDeduplicator* const type_name_deduplicator_;
-
- // Minimum size of an allocation for which an allocation bucket will be
- // broken down with children.
- uint32_t breakdown_threshold_bytes_;
-
- DISALLOW_COPY_AND_ASSIGN(HeapDumpWriter);
-};
-
-} // namespace internal
} // namespace trace_event
} // namespace base
« no previous file with comments | « no previous file | base/trace_event/heap_profiler_heap_dump_writer.cc » ('j') | base/trace_event/heap_profiler_heap_dump_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698