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

Unified Diff: runtime/observatory/lib/src/elements/memory/graph.dart

Issue 2996803002: Add current rss and embedder name to Observatory (Closed)
Patch Set: Rebase and Merge Created 3 years, 4 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/observatory/lib/src/elements/memory/graph.dart
diff --git a/runtime/observatory/lib/src/elements/memory/graph.dart b/runtime/observatory/lib/src/elements/memory/graph.dart
index f43cd3e9293f1edb650de9df27809e996a2a185a..537767d476f67b2294b57b8e17fddb117f8001f6 100644
--- a/runtime/observatory/lib/src/elements/memory/graph.dart
+++ b/runtime/observatory/lib/src/elements/memory/graph.dart
@@ -41,7 +41,8 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
Stream<IsolateSelectedEvent> get onIsolateSelected =>
_onIsolateSelected.stream;
- M.VM _vm;
+ M.VMRef _vm;
+ M.VMRepository _vms;
M.IsolateRepository _isolates;
M.EventRepository _events;
StreamSubscription _onGCSubscription;
@@ -49,17 +50,19 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
StreamSubscription _onConnectionClosedSubscription;
Timer _onTimer;
- M.VM get vm => _vm;
+ M.VMRef get vm => _vm;
- factory MemoryGraphElement(
- M.VM vm, M.IsolateRepository isolates, M.EventRepository events,
+ factory MemoryGraphElement(M.VMRef vm, M.VMRepository vms,
+ M.IsolateRepository isolates, M.EventRepository events,
{RenderingQueue queue}) {
assert(vm != null);
+ assert(vms != null);
assert(isolates != null);
assert(events != null);
MemoryGraphElement e = document.createElement(tag.name);
e._r = new RenderingScheduler(e, queue: queue);
e._vm = vm;
+ e._vms = vms;
e._isolates = isolates;
e._events = events;
return e;
@@ -70,13 +73,13 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
var sample = now.subtract(_window);
while (sample.isBefore(now)) {
_ts.add(sample);
- _vmSamples.add(0);
+ _vmSamples.add(<int>[0, 0]);
_isolateUsedSamples.add([]);
_isolateFreeSamples.add([]);
sample = sample.add(_period);
}
_ts.add(now);
- _vmSamples.add(0);
+ _vmSamples.add(<int>[0, 0]);
_isolateUsedSamples.add([]);
_isolateFreeSamples.add([]);
}
@@ -109,7 +112,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
}
final List<DateTime> _ts = <DateTime>[];
- final List<int> _vmSamples = <int>[];
+ final List<List<int>> _vmSamples = <List<int>>[];
final List<M.IsolateRef> _seenIsolates = <M.IsolateRef>[];
final List<List<int>> _isolateUsedSamples = <List<int>>[];
final List<List<int>> _isolateFreeSamples = <List<int>>[];
@@ -123,6 +126,12 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
void render() {
if (_previewed != null || _hovered != null) return;
+ // cache data of hoverboards
+ final ts = new List<DateTime>.from(_ts);
+ final vmSamples = new List<List<int>>.from(_vmSamples);
+ final isolateFreeSamples = new List<List<int>>.from(_isolateFreeSamples);
+ final isolateUsedSamples = new List<List<int>>.from(_isolateUsedSamples);
+
final now = _ts.last;
final nativeComponents = 1;
final legend = new DivElement();
@@ -144,15 +153,16 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
]));
// The stacked line chart sorts from top to bottom
final rows = new List.generate(_ts.length, (sampleIndex) {
- final free = _isolateFreeSamples[sampleIndex];
- final used = _isolateUsedSamples[sampleIndex];
+ final free = isolateFreeSamples[sampleIndex];
+ final used = isolateUsedSamples[sampleIndex];
+ final isolates = _isolateIndex.keys.expand((key) {
+ final isolateIndex = _isolateIndex[key];
+ return <int>[free[isolateIndex], used[isolateIndex]];
+ });
return [
- _ts[sampleIndex].difference(now).inMicroseconds,
- _vmSamples[sampleIndex]
- ]..addAll(_isolateIndex.keys.expand((key) {
- final isolateIndex = _isolateIndex[key];
- return [free[isolateIndex], used[isolateIndex]];
- }));
+ ts[sampleIndex].difference(now).inMicroseconds,
+ vmSamples[sampleIndex][1] ?? 1000000
+ ]..addAll(isolates);
});
final scale = new LinearScale()..domain = [(-_window).inMicroseconds, 0];
@@ -169,13 +179,15 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
final area = new CartesianArea(host, data, config, state: state)
..theme = theme;
area.addChartBehavior(new Hovercard(builder: (int column, int row) {
- final data = rows[row];
if (column == 1) {
- return _formatNativeOvercard(data[1]);
+ final data = vmSamples[row];
+ return _formatNativeOvercard(data[0], data[1]);
}
final isolate = _seenIsolates[column - 2];
- final index = _isolateIndex[isolate.id] * 2 + 2;
- return _formatIsolateOvercard(isolate.name, data[index], data[index + 1]);
+ final index = _isolateIndex[isolate.id];
+ final free = isolateFreeSamples[row][index];
+ final used = isolateUsedSamples[row][index];
+ return _formatIsolateOvercard(isolate.name, free, used);
}));
area.draw();
@@ -198,9 +210,10 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
_running = true;
final now = new DateTime.now();
final start = now.subtract(_window);
+ final vm = await _vms.get(_vm);
// The Service classes order isolates from the older to the newer
final isolates =
- (await Future.wait(_vm.isolates.map(_isolates.get))).reversed.toList();
+ (await Future.wait(vm.isolates.map(_isolates.get))).reversed.toList();
while (_ts.first.isBefore(start)) {
_ts.removeAt(0);
_vmSamples.removeAt(0);
@@ -255,7 +268,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
_isolateUsedSamples.add(isolateUsedSample);
_isolateFreeSamples.add(isolateFreeSample);
- _vmSamples.add(vm.heapAllocatedMemoryUsage);
+ _vmSamples.add(<int>[vm.currentRSS, vm.heapAllocatedMemoryUsage]);
_ts.add(now);
}
@@ -270,7 +283,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
_isolateUsedSamples.add(isolateUsedSample);
_isolateFreeSamples.add(isolateFreeSample);
- _vmSamples.add(vm.heapAllocatedMemoryUsage);
+ _vmSamples.add(<int>[vm.currentRSS, vm.heapAllocatedMemoryUsage]);
_ts.add(now);
_r.dirty();
@@ -325,22 +338,35 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
return '${name} ($usedStr / $capacityStr)';
}
- static HtmlElement _formatNativeOvercard(int heap) => new DivElement()
- ..children = [
+ static HtmlElement _formatNativeOvercard(int currentRSS, int heap) =>
new DivElement()
- ..classes = ['hovercard-title']
- ..text = 'Native',
- new DivElement()
- ..classes = ['hovercard-measure', 'hovercard-multi']
..children = [
new DivElement()
- ..classes = ['hovercard-measure-label']
- ..text = 'Heap',
+ ..classes = ['hovercard-title']
+ ..text = 'Native',
+ new DivElement()
+ ..classes = ['hovercard-measure', 'hovercard-multi']
+ ..children = [
+ new DivElement()
+ ..classes = ['hovercard-measure-label']
+ ..text = 'Total Memory Usage',
+ new DivElement()
+ ..classes = ['hovercard-measure-value']
+ ..text = currentRSS != null
+ ? Utils.formatSize(currentRSS)
+ : "unavailable",
+ ],
new DivElement()
- ..classes = ['hovercard-measure-value']
- ..text = Utils.formatSize(heap),
- ]
- ];
+ ..classes = ['hovercard-measure', 'hovercard-multi']
+ ..children = [
+ new DivElement()
+ ..classes = ['hovercard-measure-label']
+ ..text = 'Native Heap',
+ new DivElement()
+ ..classes = ['hovercard-measure-value']
+ ..text = heap != null ? Utils.formatSize(heap) : "unavailable",
+ ]
+ ];
static HtmlElement _formatIsolateOvercard(String name, int free, int used) {
final capacity = free + used;
« no previous file with comments | « runtime/observatory/lib/src/elements/memory/dashboard.dart ('k') | runtime/observatory/lib/src/elements/vm_view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698