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

Unified Diff: runtime/vm/profiler_service.h

Issue 2748403002: Added page to Observatory to display native memory allocation information. (Closed)
Patch Set: Added tests to verify sample tries inclusive/exclusive allocations. Element now displays memory con… Created 3 years, 9 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: runtime/vm/profiler_service.h
diff --git a/runtime/vm/profiler_service.h b/runtime/vm/profiler_service.h
index d9205b3b7a1ee851107a8f1778c3f4e0d1de36b1..ab7f72ba09294621232f0e6da69354813280d002 100644
--- a/runtime/vm/profiler_service.h
+++ b/runtime/vm/profiler_service.h
@@ -9,6 +9,7 @@
#include "vm/code_observers.h"
#include "vm/globals.h"
#include "vm/growable_array.h"
+#include "vm/hash_map.h"
#include "vm/object.h"
#include "vm/tags.h"
#include "vm/thread_interrupter.h"
@@ -29,8 +30,30 @@ class ProfileCodeTable;
class RawCode;
class RawFunction;
class SampleFilter;
+class ProcessedSample;
class ProcessedSampleBuffer;
+class AllocationKeyValueTrait {
+ public:
+ typedef intptr_t Key;
Cutch 2017/03/16 20:38:16 what is the key?
bkonyi 2017/03/16 20:48:40 Size of the allocation. Will add comment/better na
bkonyi 2017/03/21 01:53:24 Removed.
+ typedef intptr_t Value;
Cutch 2017/03/16 20:38:16 what is the value?
bkonyi 2017/03/16 20:48:40 The number of allocations of the size represented
bkonyi 2017/03/21 01:53:24 Removed.
+
+ struct Pair {
+ Key key;
+ Value value;
+ Pair() : key(), value(-1) {}
+ Pair(const Key key, const Value value) : key(key), value(value) {}
+ Pair(const Pair& other) : key(other.key), value(other.value) {}
+ };
+
+ static Key KeyOf(Pair kv) { return kv.key; }
+ static Value ValueOf(Pair kv) { return kv.value; }
+ static uintptr_t Hashcode(Key key) { return key; }
+ static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; }
+};
+
+typedef DirectChainedHashMap<AllocationKeyValueTrait> AllocationHashMap;
+
class ProfileFunctionSourcePosition {
public:
explicit ProfileFunctionSourcePosition(TokenPosition token_pos);
@@ -83,12 +106,15 @@ class ProfileFunction : public ZoneAllocated {
intptr_t exclusive_ticks() const { return exclusive_ticks_; }
intptr_t inclusive_ticks() const { return inclusive_ticks_; }
-
void IncInclusiveTicks() { inclusive_ticks_++; }
-
void Tick(bool exclusive,
intptr_t inclusive_serial,
- TokenPosition token_position);
+ TokenPosition token_position,
+ ProcessedSample* sample);
+
+ bool contains_native_allocation() const {
+ return contains_native_allocation_;
+ }
static const char* KindToCString(Kind kind);
@@ -119,6 +145,11 @@ class ProfileFunction : public ZoneAllocated {
intptr_t inclusive_ticks_;
intptr_t inclusive_serial_;
+ void AccumulateAllocation(intptr_t allocation_size, bool exclusive);
+ bool contains_native_allocation_;
+ AllocationHashMap exclusive_native_allocations_;
+ AllocationHashMap inclusive_native_allocations_;
+
void PrintToJSONObject(JSONObject* func);
// A |ProfileCode| that contains this function.
void AddProfileCode(intptr_t code_table_index);
@@ -193,6 +224,10 @@ class ProfileCode : public ZoneAllocated {
}
void IncInclusiveTicks() { inclusive_ticks_++; }
+ bool contains_native_allocation() const {
+ return contains_native_allocation_;
+ }
+
bool IsOptimizedDart() const;
RawCode* code() const { return code_.raw(); }
@@ -205,8 +240,9 @@ class ProfileCode : public ZoneAllocated {
void PrintToJSONArray(JSONArray* codes);
private:
- void Tick(uword pc, bool exclusive, intptr_t serial);
+ void Tick(uword pc, bool exclusive, intptr_t serial, ProcessedSample* sample);
void TickAddress(uword pc, bool exclusive);
+ void AccumulateAllocation(intptr_t allocation_size, bool exclusive);
ProfileFunction* SetFunctionAndName(ProfileFunctionTable* table);
@@ -227,6 +263,10 @@ class ProfileCode : public ZoneAllocated {
intptr_t inclusive_ticks_;
intptr_t inclusive_serial_;
+ AllocationHashMap exclusive_native_allocations_;
+ AllocationHashMap inclusive_native_allocations_;
+ bool contains_native_allocation_;
+
const Code& code_;
char* name_;
int64_t compile_timestamp_;
@@ -258,6 +298,13 @@ class ProfileTrieNode : public ZoneAllocated {
intptr_t count() const { return count_; }
void Tick() { count_++; }
+ void IncrementAllocation(intptr_t allocation, bool exclusive) {
+ ASSERT(allocation >= 0);
+ if (exclusive) {
+ exclusive_allocations_ += allocation;
+ }
+ inclusive_allocations_ += allocation;
+ }
intptr_t NumChildren() const { return children_.length(); }
@@ -284,6 +331,8 @@ class ProfileTrieNode : public ZoneAllocated {
intptr_t table_index_;
intptr_t count_;
+ intptr_t exclusive_allocations_;
+ intptr_t inclusive_allocations_;
ZoneGrowableArray<ProfileTrieNode*> children_;
intptr_t frame_id_;

Powered by Google App Engine
This is Rietveld 408576698