From 2f5a59e658cfa867a74e9d2672058463b422fcde Mon Sep 17 00:00:00 2001 From: Carlo Bernaschina Date: Mon, 14 Aug 2017 15:45:08 -0700 Subject: [PATCH] Revert "Add current rss and embedder name to Observatory" This reverts commit ce736d3ef009bf334a92d5b7d354fc0b04805b4f. TBR=zra@google.com Review-Url: https://codereview.chromium.org/2999933002 . --- runtime/bin/main.cc | 11 --- runtime/bin/process_android.cc | 26 +++-- runtime/bin/process_linux.cc | 26 +++-- runtime/include/dart_tools_api.h | 43 --------- runtime/observatory/lib/models.dart | 1 - runtime/observatory/lib/repositories.dart | 1 - runtime/observatory/lib/src/app/page.dart | 7 +- .../lib/src/elements/memory/dashboard.dart | 13 +-- .../lib/src/elements/memory/graph.dart | 94 +++++++------------ .../observatory/lib/src/elements/vm_view.dart | 47 +--------- .../lib/src/models/objects/vm.dart | 3 - .../lib/src/models/repositories/vm.dart | 9 -- .../observatory/lib/src/repositories/vm.dart | 14 --- .../observatory/lib/src/service/object.dart | 14 +-- runtime/observatory/observatory_sources.gypi | 2 - .../observatory_ui/mocks/objects/vm.dart | 4 - .../observatory/tests/service/vm_test.dart | 5 - runtime/vm/benchmark_test.cc | 2 +- runtime/vm/dart_api_impl.cc | 12 --- runtime/vm/metrics.cc | 6 +- runtime/vm/metrics.h | 6 -- runtime/vm/os.h | 3 + runtime/vm/os_android.cc | 8 ++ runtime/vm/os_fuchsia.cc | 10 ++ runtime/vm/os_linux.cc | 8 ++ runtime/vm/os_macos.cc | 8 ++ runtime/vm/os_win.cc | 6 ++ runtime/vm/service.cc | 60 +----------- runtime/vm/service.h | 9 -- 29 files changed, 123 insertions(+), 335 deletions(-) delete mode 100644 runtime/observatory/lib/src/models/repositories/vm.dart delete mode 100644 runtime/observatory/lib/src/repositories/vm.dart diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc index ffbc2e73813..28d64117c92 100644 --- a/runtime/bin/main.cc +++ b/runtime/bin/main.cc @@ -1359,16 +1359,6 @@ static bool FileModifiedCallback(const char* url, int64_t since) { return modified; } -static void EmbedderInformationCallback(Dart_EmbedderInformation* info) { - int64_t max_rss = Process::MaxRSS(); - int64_t current_rss = Process::CurrentRSS(); - - info->version = DART_EMBEDDER_INFORMATION_CURRENT_VERSION; - info->name = "Dart VM"; - info->max_rss = max_rss >= 0 ? max_rss : 0; - info->current_rss = current_rss >= 0 ? current_rss : 0; -} - static void GenerateAppAOTSnapshot() { if (use_blobs) { Snapshot::GenerateAppAOTAsBlobs(snapshot_filename); @@ -1818,7 +1808,6 @@ void main(int argc, char** argv) { Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback, &ServiceStreamCancelCallback); Dart_SetFileModifiedCallback(&FileModifiedCallback); - Dart_SetEmbedderInformationCallback(&EmbedderInformationCallback); // Run the main isolate until we aren't told to restart. while (RunMainIsolate(script_name, &dart_options)) { diff --git a/runtime/bin/process_android.cc b/runtime/bin/process_android.cc index 9b307f3ed6f..66fc2805230 100644 --- a/runtime/bin/process_android.cc +++ b/runtime/bin/process_android.cc @@ -859,27 +859,25 @@ intptr_t Process::CurrentProcessId() { return static_cast(getpid()); } -static void SaveErrorAndClose(FILE* file) { - int actual_errno = errno; - fclose(file); - errno = actual_errno; -} - int64_t Process::CurrentRSS() { // The second value in /proc/self/statm is the current RSS in pages. - // It is not possible to use getrusage() because the interested fields are not - // implemented by the linux kernel. - FILE* statm = fopen("/proc/self/statm", "r"); + File* statm = File::Open("/proc/self/statm", File::kRead); if (statm == NULL) { return -1; } - int64_t current_rss_pages = 0; - int matches = fscanf(statm, "%*s%" Pd64 "", ¤t_rss_pages); - if (matches != 1) { - SaveErrorAndClose(statm); + RefCntReleaseScope releaser(statm); + const intptr_t statm_length = 1 * KB; + void* buffer = reinterpret_cast(Dart_ScopeAllocate(statm_length)); + const intptr_t statm_read = statm->Read(buffer, statm_length); + if (statm_read <= 0) { + return -1; + } + int64_t current_rss_pages = 0; + int matches = sscanf(reinterpret_cast(buffer), "%*s%" Pd64 "", + ¤t_rss_pages); + if (matches != 1) { return -1; } - fclose(statm); return current_rss_pages * getpagesize(); } diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc index cbaa0128388..1ab9a130ae7 100644 --- a/runtime/bin/process_linux.cc +++ b/runtime/bin/process_linux.cc @@ -860,27 +860,25 @@ intptr_t Process::CurrentProcessId() { return static_cast(getpid()); } -static void SaveErrorAndClose(FILE* file) { - int actual_errno = errno; - fclose(file); - errno = actual_errno; -} - int64_t Process::CurrentRSS() { // The second value in /proc/self/statm is the current RSS in pages. - // It is not possible to use getrusage() because the interested fields are not - // implemented by the linux kernel. - FILE* statm = fopen("/proc/self/statm", "r"); + File* statm = File::Open("/proc/self/statm", File::kRead); if (statm == NULL) { return -1; } - int64_t current_rss_pages = 0; - int matches = fscanf(statm, "%*s%" Pd64 "", ¤t_rss_pages); - if (matches != 1) { - SaveErrorAndClose(statm); + RefCntReleaseScope releaser(statm); + const intptr_t statm_length = 1 * KB; + void* buffer = reinterpret_cast(Dart_ScopeAllocate(statm_length)); + const intptr_t statm_read = statm->Read(buffer, statm_length); + if (statm_read <= 0) { + return -1; + } + int64_t current_rss_pages = 0; + int matches = sscanf(reinterpret_cast(buffer), "%*s%" Pd64 "", + ¤t_rss_pages); + if (matches != 1) { return -1; } - fclose(statm); return current_rss_pages * getpagesize(); } diff --git a/runtime/include/dart_tools_api.h b/runtime/include/dart_tools_api.h index 11982e36c90..e7440f8f9e9 100644 --- a/runtime/include/dart_tools_api.h +++ b/runtime/include/dart_tools_api.h @@ -765,49 +765,6 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback( Dart_ServiceRequestCallback callback, void* user_data); -/** - * Embedder information which can be requested by the VM for internal or - * reporting purposes. - * - * The pointers in this structure are not going to be cached or freed by the VM. - */ - - #define DART_EMBEDDER_INFORMATION_CURRENT_VERSION (0x00000001) - -typedef struct { - int32_t version; - const char* name; // [optional] The name of the embedder - uintptr_t current_rss; // [optional] the current RSS of the embedder - uintptr_t max_rss; // [optional] the maximum RSS of the embedder -} Dart_EmbedderInformation; - -/** - * Callback provided by the embedder that is used by the vm to request - * information. - * - * \return Returns a pointer to a Dart_EmbedderInformation structure. - * The embedder keeps the ownership of the structure and any field in it. - * The embedder must ensure that the structure will remain valid until the - * next invokation of the callback. - */ -typedef void (*Dart_EmbedderInformationCallback)( - Dart_EmbedderInformation* info); - -/** - * Register a Dart_ServiceRequestCallback to be called to handle - * requests for the named rpc. The callback will be invoked without a - * current isolate. - * - * \param method The name of the command that this callback is responsible for. - * \param callback The callback to invoke. - * \param user_data The user data passed to the callback. - * - * NOTE: If multiple callbacks with the same name are registered, only - * the last callback registered will be remembered. - */ -DART_EXPORT void Dart_SetEmbedderInformationCallback( - Dart_EmbedderInformationCallback callback); - /* * ======== * Event Streams diff --git a/runtime/observatory/lib/models.dart b/runtime/observatory/lib/models.dart index 359b371b93f..18ca5c9480e 100644 --- a/runtime/observatory/lib/models.dart +++ b/runtime/observatory/lib/models.dart @@ -93,4 +93,3 @@ part 'src/models/repositories/target.dart'; part 'src/models/repositories/top_retaining_instances.dart'; part 'src/models/repositories/type_arguments.dart'; part 'src/models/repositories/unlinked_call.dart'; -part 'src/models/repositories/vm.dart'; diff --git a/runtime/observatory/lib/repositories.dart b/runtime/observatory/lib/repositories.dart index 3e884111d36..90ec2a9f496 100644 --- a/runtime/observatory/lib/repositories.dart +++ b/runtime/observatory/lib/repositories.dart @@ -51,4 +51,3 @@ part 'src/repositories/target.dart'; part 'src/repositories/top_retaining_instances.dart'; part 'src/repositories/type_arguments.dart'; part 'src/repositories/unlinked_call.dart'; -part 'src/repositories/vm.dart'; diff --git a/runtime/observatory/lib/src/app/page.dart b/runtime/observatory/lib/src/app/page.dart index eb35b840979..8500d32e877 100644 --- a/runtime/observatory/lib/src/app/page.dart +++ b/runtime/observatory/lib/src/app/page.dart @@ -35,7 +35,6 @@ final _subtypeTestCacheRepository = new SubtypeTestCacheRepository(); final _topRetainingInstancesRepository = new TopRetainingInstancesRepository(); final _typeArgumentsRepository = new TypeArgumentsRepository(); final _unlinkedCallRepository = new UnlinkedCallRepository(); -final _vmrepository = new VMRepository(); class IsolateNotFound implements Exception { String isolateId; @@ -171,7 +170,7 @@ class VMPage extends MatchingPage { } app.vm.reload().then((VM vm) { container.children = [ - new VMViewElement(vm, _vmrepository, app.events, app.notifications, + new VMViewElement(vm, app.events, app.notifications, new IsolateRepository(app.vm), _scriptRepository, queue: app.queue) ]; @@ -709,8 +708,8 @@ class MemoryDashboardPage extends MatchingPage { // Preload all isolates to avoid sorting problems. await Future.wait(vm.isolates.map((i) => i.load())); container.children = [ - new MemoryDashboardElement(vm, _vmrepository, new IsolateRepository(vm), - editor, _allocationProfileRepository, app.events, app.notifications, + new MemoryDashboardElement(vm, new IsolateRepository(vm), editor, + _allocationProfileRepository, app.events, app.notifications, queue: app.queue) ]; }).catchError((e, stack) { diff --git a/runtime/observatory/lib/src/elements/memory/dashboard.dart b/runtime/observatory/lib/src/elements/memory/dashboard.dart index 0597fa8217b..2aa299ef5e5 100644 --- a/runtime/observatory/lib/src/elements/memory/dashboard.dart +++ b/runtime/observatory/lib/src/elements/memory/dashboard.dart @@ -41,19 +41,17 @@ class MemoryDashboardElement extends HtmlElement implements Renderable { Stream> get onRendered => _r.onRendered; M.VMRef _vm; - M.VMRepository _vms; M.IsolateRepository _isolates; M.EditorRepository _editor; M.AllocationProfileRepository _allocations; M.EventRepository _events; M.NotificationRepository _notifications; - M.VMRef get vm => _vm; + M.VM get vm => _vm; M.NotificationRepository get notifications => _notifications; factory MemoryDashboardElement( - M.VMRef vm, - M.VMRepository vms, + M.VM vm, M.IsolateRepository isolates, M.EditorRepository editor, M.AllocationProfileRepository allocations, @@ -61,7 +59,6 @@ class MemoryDashboardElement extends HtmlElement implements Renderable { M.NotificationRepository notifications, {RenderingQueue queue}) { assert(vm != null); - assert(vms != null); assert(isolates != null); assert(editor != null); assert(allocations != null); @@ -70,7 +67,6 @@ class MemoryDashboardElement extends HtmlElement implements Renderable { MemoryDashboardElement e = document.createElement(tag.name); e._r = new RenderingScheduler(e, queue: queue); e._vm = vm; - e._vms = vms; e._isolates = isolates; e._editor = editor; e._allocations = allocations; @@ -100,9 +96,8 @@ class MemoryDashboardElement extends HtmlElement implements Renderable { void render() { if (_graph == null) { - _graph = - new MemoryGraphElement(vm, _vms, _isolates, _events, queue: _r.queue) - ..onIsolateSelected.listen(_onIsolateSelected); + _graph = new MemoryGraphElement(vm, _isolates, _events, queue: _r.queue) + ..onIsolateSelected.listen(_onIsolateSelected); } children = [ navBar([new NavNotifyElement(_notifications, queue: _r.queue)]), diff --git a/runtime/observatory/lib/src/elements/memory/graph.dart b/runtime/observatory/lib/src/elements/memory/graph.dart index 537767d476f..f43cd3e9293 100644 --- a/runtime/observatory/lib/src/elements/memory/graph.dart +++ b/runtime/observatory/lib/src/elements/memory/graph.dart @@ -41,8 +41,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable { Stream get onIsolateSelected => _onIsolateSelected.stream; - M.VMRef _vm; - M.VMRepository _vms; + M.VM _vm; M.IsolateRepository _isolates; M.EventRepository _events; StreamSubscription _onGCSubscription; @@ -50,19 +49,17 @@ class MemoryGraphElement extends HtmlElement implements Renderable { StreamSubscription _onConnectionClosedSubscription; Timer _onTimer; - M.VMRef get vm => _vm; + M.VM get vm => _vm; - factory MemoryGraphElement(M.VMRef vm, M.VMRepository vms, - M.IsolateRepository isolates, M.EventRepository events, + factory MemoryGraphElement( + M.VM vm, 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; @@ -73,13 +70,13 @@ class MemoryGraphElement extends HtmlElement implements Renderable { var sample = now.subtract(_window); while (sample.isBefore(now)) { _ts.add(sample); - _vmSamples.add([0, 0]); + _vmSamples.add(0); _isolateUsedSamples.add([]); _isolateFreeSamples.add([]); sample = sample.add(_period); } _ts.add(now); - _vmSamples.add([0, 0]); + _vmSamples.add(0); _isolateUsedSamples.add([]); _isolateFreeSamples.add([]); } @@ -112,7 +109,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable { } final List _ts = []; - final List> _vmSamples = >[]; + final List _vmSamples = []; final List _seenIsolates = []; final List> _isolateUsedSamples = >[]; final List> _isolateFreeSamples = >[]; @@ -126,12 +123,6 @@ class MemoryGraphElement extends HtmlElement implements Renderable { void render() { if (_previewed != null || _hovered != null) return; - // cache data of hoverboards - final ts = new List.from(_ts); - final vmSamples = new List>.from(_vmSamples); - final isolateFreeSamples = new List>.from(_isolateFreeSamples); - final isolateUsedSamples = new List>.from(_isolateUsedSamples); - final now = _ts.last; final nativeComponents = 1; final legend = new DivElement(); @@ -153,16 +144,15 @@ 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 isolates = _isolateIndex.keys.expand((key) { - final isolateIndex = _isolateIndex[key]; - return [free[isolateIndex], used[isolateIndex]]; - }); + final free = _isolateFreeSamples[sampleIndex]; + final used = _isolateUsedSamples[sampleIndex]; return [ - ts[sampleIndex].difference(now).inMicroseconds, - vmSamples[sampleIndex][1] ?? 1000000 - ]..addAll(isolates); + _ts[sampleIndex].difference(now).inMicroseconds, + _vmSamples[sampleIndex] + ]..addAll(_isolateIndex.keys.expand((key) { + final isolateIndex = _isolateIndex[key]; + return [free[isolateIndex], used[isolateIndex]]; + })); }); final scale = new LinearScale()..domain = [(-_window).inMicroseconds, 0]; @@ -179,15 +169,13 @@ 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) { - final data = vmSamples[row]; - return _formatNativeOvercard(data[0], data[1]); + return _formatNativeOvercard(data[1]); } final isolate = _seenIsolates[column - 2]; - final index = _isolateIndex[isolate.id]; - final free = isolateFreeSamples[row][index]; - final used = isolateUsedSamples[row][index]; - return _formatIsolateOvercard(isolate.name, free, used); + final index = _isolateIndex[isolate.id] * 2 + 2; + return _formatIsolateOvercard(isolate.name, data[index], data[index + 1]); })); area.draw(); @@ -210,10 +198,9 @@ 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); @@ -268,7 +255,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable { _isolateUsedSamples.add(isolateUsedSample); _isolateFreeSamples.add(isolateFreeSample); - _vmSamples.add([vm.currentRSS, vm.heapAllocatedMemoryUsage]); + _vmSamples.add(vm.heapAllocatedMemoryUsage); _ts.add(now); } @@ -283,7 +270,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable { _isolateUsedSamples.add(isolateUsedSample); _isolateFreeSamples.add(isolateFreeSample); - _vmSamples.add([vm.currentRSS, vm.heapAllocatedMemoryUsage]); + _vmSamples.add(vm.heapAllocatedMemoryUsage); _ts.add(now); _r.dirty(); @@ -338,35 +325,22 @@ class MemoryGraphElement extends HtmlElement implements Renderable { return '${name} ($usedStr / $capacityStr)'; } - static HtmlElement _formatNativeOvercard(int currentRSS, int heap) => + static HtmlElement _formatNativeOvercard(int heap) => new DivElement() + ..children = [ new DivElement() + ..classes = ['hovercard-title'] + ..text = 'Native', + new DivElement() + ..classes = ['hovercard-measure', 'hovercard-multi'] ..children = [ new DivElement() - ..classes = ['hovercard-title'] - ..text = 'Native', + ..classes = ['hovercard-measure-label'] + ..text = 'Heap', 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', '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", - ] - ]; + ..classes = ['hovercard-measure-value'] + ..text = Utils.formatSize(heap), + ] + ]; static HtmlElement _formatIsolateOvercard(String name, int free, int used) { final capacity = free + used; diff --git a/runtime/observatory/lib/src/elements/vm_view.dart b/runtime/observatory/lib/src/elements/vm_view.dart index c02ef47a8c4..fd37dd21646 100644 --- a/runtime/observatory/lib/src/elements/vm_view.dart +++ b/runtime/observatory/lib/src/elements/vm_view.dart @@ -34,7 +34,6 @@ class VMViewElement extends HtmlElement implements Renderable { Stream> get onRendered => _r.onRendered; M.VM _vm; - M.VMRepository _vms; M.EventRepository _events; M.NotificationRepository _notifications; M.IsolateRepository _isolates; @@ -48,22 +47,17 @@ class VMViewElement extends HtmlElement implements Renderable { factory VMViewElement( M.VM vm, - M.VMRepository vms, M.EventRepository events, M.NotificationRepository notifications, M.IsolateRepository isolates, M.ScriptRepository scripts, {RenderingQueue queue}) { assert(vm != null); - assert(vms != null); assert(events != null); assert(notifications != null); - assert(isolates != null); - assert(scripts != null); VMViewElement e = document.createElement(tag.name); e._r = new RenderingScheduler(e, queue: queue); e._vm = vm; - e._vms = vms; e._events = events; e._notifications = notifications; e._isolates = isolates; @@ -105,14 +99,13 @@ class VMViewElement extends HtmlElement implements Renderable { new NavRefreshElement(queue: _r.queue) ..onRefresh.listen((e) async { e.element.disabled = true; - _vm = await _vms.get(_vm); _r.dirty(); }), new NavNotifyElement(_notifications, queue: _r.queue) ]), new DivElement() ..classes = ['content-centered-big'] - ..children = [ + ..children = [ new HeadingElement.h1()..text = 'VM', new HRElement(), new DivElement() @@ -138,16 +131,6 @@ class VMViewElement extends HtmlElement implements Renderable { ..classes = ['memberValue'] ..text = _vm.version ], - new DivElement() - ..classes = ['memberItem'] - ..children = [ - new DivElement() - ..classes = ['memberName'] - ..text = 'embedder', - new DivElement() - ..classes = ['memberValue'] - ..text = _vm.embedder ?? "UNKNOWN" - ], new DivElement() ..classes = ['memberItem'] ..children = [ @@ -196,21 +179,7 @@ class VMViewElement extends HtmlElement implements Renderable { ..text = 'peak memory', new DivElement() ..classes = ['memberValue'] - ..text = _vm.maxRSS != null - ? Utils.formatSize(_vm.maxRSS) - : "unavailable" - ], - new DivElement() - ..classes = ['memberItem'] - ..children = [ - new DivElement() - ..classes = ['memberName'] - ..text = 'current memory', - new DivElement() - ..classes = ['memberValue'] - ..text = _vm.currentRSS != null - ? Utils.formatSize(_vm.currentRSS) - : "unavailable" + ..text = Utils.formatSize(_vm.maxRSS) ], new DivElement() ..classes = ['memberItem'] @@ -231,12 +200,8 @@ class VMViewElement extends HtmlElement implements Renderable { ..text = 'native heap memory', new DivElement() ..classes = ['memberValue'] - ..text = _vm.heapAllocatedMemoryUsage != null - ? Utils.formatSize(_vm.heapAllocatedMemoryUsage) - : 'unavailable' - ..title = _vm.heapAllocatedMemoryUsage != null - ? '${_vm.heapAllocatedMemoryUsage} bytes' - : null + ..text = Utils.formatSize(_vm.heapAllocatedMemoryUsage) + ..title = '${_vm.heapAllocatedMemoryUsage} bytes' ], new DivElement() ..classes = ['memberItem'] @@ -246,9 +211,7 @@ class VMViewElement extends HtmlElement implements Renderable { ..text = 'native heap allocation count', new DivElement() ..classes = ['memberValue'] - ..text = _vm.heapAllocationCount != null - ? '${_vm.heapAllocationCount}' - : 'unavailable' + ..text = '${_vm.heapAllocationCount}' ], new BRElement(), new DivElement() diff --git a/runtime/observatory/lib/src/models/objects/vm.dart b/runtime/observatory/lib/src/models/objects/vm.dart index b2bfd4de2a2..c71995e626f 100644 --- a/runtime/observatory/lib/src/models/objects/vm.dart +++ b/runtime/observatory/lib/src/models/objects/vm.dart @@ -26,8 +26,6 @@ abstract class VM implements VMRef { /// The Dart VM version string. String get version; - String get embedder; - /// The amount of memory currently allocated by native code in zones. int get nativeZoneMemoryUsage; @@ -41,7 +39,6 @@ abstract class VM implements VMRef { int get heapAllocationCount; int get maxRSS; - int get currentRSS; /// The time that the VM started in milliseconds since the epoch. /// diff --git a/runtime/observatory/lib/src/models/repositories/vm.dart b/runtime/observatory/lib/src/models/repositories/vm.dart deleted file mode 100644 index fd646bc37ac..00000000000 --- a/runtime/observatory/lib/src/models/repositories/vm.dart +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of models; - -abstract class VMRepository { - Future get(VMRef ref); -} diff --git a/runtime/observatory/lib/src/repositories/vm.dart b/runtime/observatory/lib/src/repositories/vm.dart deleted file mode 100644 index 514e3741a84..00000000000 --- a/runtime/observatory/lib/src/repositories/vm.dart +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -part of repositories; - -class VMRepository implements M.VMRepository { - Future get(M.VMRef ref) async { - S.VM vm = ref as S.VM; - assert(vm != null); - await vm.reload(); - return vm; - } -} diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart index ef9499cd4cf..7d238edac02 100644 --- a/runtime/observatory/lib/src/service/object.dart +++ b/runtime/observatory/lib/src/service/object.dart @@ -669,7 +669,6 @@ abstract class VM extends ServiceObjectOwner implements M.VM { String version = 'unknown'; String hostCPU; String targetCPU; - String embedder; int architectureBits; bool assertsEnabled = false; bool typeChecksEnabled = false; @@ -677,8 +676,7 @@ abstract class VM extends ServiceObjectOwner implements M.VM { int pid = 0; int heapAllocatedMemoryUsage = 0; int heapAllocationCount = 0; - int maxRSS; - int currentRSS; + int maxRSS = 0; bool profileVM = false; DateTime startTime; DateTime refreshTime; @@ -980,11 +978,13 @@ abstract class VM extends ServiceObjectOwner implements M.VM { nativeZoneMemoryUsage = map['_nativeZoneMemoryUsage']; } pid = map['pid']; - heapAllocatedMemoryUsage = map['_heapAllocatedMemoryUsage']; - heapAllocationCount = map['_heapAllocationCount']; - embedder = map['_embedder']; + if (map['_heapAllocatedMemoryUsage'] != null) { + heapAllocatedMemoryUsage = map['_heapAllocatedMemoryUsage']; + } + if (map['_heapAllocationCount'] != null) { + heapAllocationCount = map['_heapAllocationCount']; + } maxRSS = map['_maxRSS']; - currentRSS = map['_currentRSS']; profileVM = map['_profilerMode'] == 'VM'; assertsEnabled = map['_assertsEnabled']; typeChecksEnabled = map['_typeChecksEnabled']; diff --git a/runtime/observatory/observatory_sources.gypi b/runtime/observatory/observatory_sources.gypi index 4569ed36d6c..496dedd03c7 100644 --- a/runtime/observatory/observatory_sources.gypi +++ b/runtime/observatory/observatory_sources.gypi @@ -230,7 +230,6 @@ 'lib/src/models/repositories/top_retaining_instances.dart', 'lib/src/models/repositories/type_arguments.dart', 'lib/src/models/repositories/unlinked_call.dart', - 'lib/src/models/repositories/vm.dart', 'lib/src/repositories/allocation_profile.dart', 'lib/src/repositories/breakpoint.dart', 'lib/src/repositories/class.dart', @@ -269,7 +268,6 @@ 'lib/src/repositories/type_arguments.dart', 'lib/src/repositories/unlinked_call.dart', 'lib/src/sample_profile/sample_profile.dart', - 'lib/src/repositories/vm.dart', 'lib/src/service/object.dart', 'lib/tracer.dart', 'lib/utils.dart', diff --git a/runtime/observatory/tests/observatory_ui/mocks/objects/vm.dart b/runtime/observatory/tests/observatory_ui/mocks/objects/vm.dart index c19ba5658c0..77fb1535a5b 100644 --- a/runtime/observatory/tests/observatory_ui/mocks/objects/vm.dart +++ b/runtime/observatory/tests/observatory_ui/mocks/objects/vm.dart @@ -17,10 +17,8 @@ class VMMock implements M.VM { final String targetCPU; final String hostCPU; final String version; - final String embedder; final int pid; final int maxRSS; - final int currentRSS; final DateTime startTime; final Iterable isolates; final int nativeZoneMemoryUsage = 0; @@ -42,10 +40,8 @@ class VMMock implements M.VM { this.targetCPU, this.hostCPU, this.version, - this.embedder, this.pid: 0, this.maxRSS: 0, - this.currentRSS: 0, this.startTime, this.isolates: const []}); } diff --git a/runtime/observatory/tests/service/vm_test.dart b/runtime/observatory/tests/service/vm_test.dart index 0f3c7d342f7..f39465e0a2b 100644 --- a/runtime/observatory/tests/service/vm_test.dart +++ b/runtime/observatory/tests/service/vm_test.dart @@ -12,11 +12,6 @@ var tests = [ VM vm = isolate.owner; expect(vm.targetCPU, isNotNull); expect(vm.architectureBits == 32 || vm.architectureBits == 64, isTrue); - expect(vm.embedder, equals("Dart VM")); - expect(vm.currentRSS, isNotNull); - expect(vm.currentRSS, greaterThan(0)); - expect(vm.maxRSS, isNotNull); - expect(vm.maxRSS, greaterThan(0)); }, ]; diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc index abb1afc288b..1161c679969 100644 --- a/runtime/vm/benchmark_test.cc +++ b/runtime/vm/benchmark_test.cc @@ -702,7 +702,7 @@ BENCHMARK(LargeMap) { } BENCHMARK_MEMORY(InitialRSS) { - benchmark->set_score(Service::MaxRSS()); + benchmark->set_score(OS::MaxRSS()); } } // namespace dart diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index d257ca00fdc..f440f32738e 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -5931,11 +5931,6 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback( return; } -DART_EXPORT void Dart_SetEmbedderInformationCallback( - Dart_EmbedderInformationCalback calback) { - return; -} - DART_EXPORT Dart_Handle Dart_SetServiceStreamCallbacks( Dart_ServiceStreamListenCallback listen_callback, Dart_ServiceStreamCancelCallback cancel_callback) { @@ -6001,13 +5996,6 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback( } } -DART_EXPORT void Dart_SetEmbedderInformationCallback( - Dart_EmbedderInformationCallback callback) { - if (FLAG_support_service) { - Service::SetEmbedderInformationCallback(callback); - } -} - DART_EXPORT Dart_Handle Dart_SetServiceStreamCallbacks( Dart_ServiceStreamListenCallback listen_callback, Dart_ServiceStreamCancelCallback cancel_callback) { diff --git a/runtime/vm/metrics.cc b/runtime/vm/metrics.cc index 94fd0bf63f4..afb7b879bc9 100644 --- a/runtime/vm/metrics.cc +++ b/runtime/vm/metrics.cc @@ -289,12 +289,8 @@ int64_t MetricIsolateCount::Value() const { return Isolate::IsolateListLength(); } -int64_t MetricCurrentRSS::Value() const { - return Service::CurrentRSS(); -} - int64_t MetricPeakRSS::Value() const { - return Service::MaxRSS(); + return OS::MaxRSS(); } #define VM_METRIC_VARIABLE(type, variable, name, unit) \ diff --git a/runtime/vm/metrics.h b/runtime/vm/metrics.h index 530cc4dd7d0..87467ce5ee5 100644 --- a/runtime/vm/metrics.h +++ b/runtime/vm/metrics.h @@ -31,7 +31,6 @@ class JSONStream; #define VM_METRIC_LIST(V) \ V(MetricIsolateCount, IsolateCount, "vm.isolate.count", kCounter) \ - V(MetricCurrentRSS, CurrentRSS, "vm.memory.current", kByte) \ V(MetricPeakRSS, PeakRSS, "vm.memory.max", kByte) class Metric { @@ -163,11 +162,6 @@ class MetricIsolateCount : public Metric { virtual int64_t Value() const; }; -class MetricCurrentRSS : public Metric { - protected: - virtual int64_t Value() const; -}; - class MetricPeakRSS : public Metric { protected: virtual int64_t Value() const; diff --git a/runtime/vm/os.h b/runtime/vm/os.h index ee37e15d9be..d1ec2149096 100644 --- a/runtime/vm/os.h +++ b/runtime/vm/os.h @@ -79,6 +79,9 @@ class OS { // Returns number of available processor cores. static int NumberOfAvailableProcessors(); + // Returns the maximium resident set size of this process. + static uintptr_t MaxRSS(); + // Sleep the currently executing thread for millis ms. static void Sleep(int64_t millis); diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc index 77357507ff3..d9da8d46fb3 100644 --- a/runtime/vm/os_android.cc +++ b/runtime/vm/os_android.cc @@ -214,6 +214,14 @@ int OS::NumberOfAvailableProcessors() { return sysconf(_SC_NPROCESSORS_ONLN); } +uintptr_t OS::MaxRSS() { + struct rusage usage; + usage.ru_maxrss = 0; + int r = getrusage(RUSAGE_SELF, &usage); + ASSERT(r == 0); + return usage.ru_maxrss * KB; +} + void OS::Sleep(int64_t millis) { int64_t micros = millis * kMicrosecondsPerMillisecond; SleepMicros(micros); diff --git a/runtime/vm/os_fuchsia.cc b/runtime/vm/os_fuchsia.cc index 11e795192f7..3781f029ba2 100644 --- a/runtime/vm/os_fuchsia.cc +++ b/runtime/vm/os_fuchsia.cc @@ -136,6 +136,16 @@ int OS::NumberOfAvailableProcessors() { return sysconf(_SC_NPROCESSORS_CONF); } +uintptr_t OS::MaxRSS() { + mx_info_task_stats_t task_stats; + mx_handle_t process = mx_process_self(); + mx_status_t status = mx_object_get_info( + process, MX_INFO_TASK_STATS, &task_stats, sizeof(task_stats), NULL, NULL); + return (status == MX_OK) + ? (task_stats.mem_private_bytes + task_stats.mem_shared_bytes) + : 0; +} + void OS::Sleep(int64_t millis) { SleepMicros(millis * kMicrosecondsPerMillisecond); } diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc index 3722ff07760..ccbc7e51e4f 100644 --- a/runtime/vm/os_linux.cc +++ b/runtime/vm/os_linux.cc @@ -221,6 +221,14 @@ int OS::NumberOfAvailableProcessors() { return sysconf(_SC_NPROCESSORS_ONLN); } +uintptr_t OS::MaxRSS() { + struct rusage usage; + usage.ru_maxrss = 0; + int r = getrusage(RUSAGE_SELF, &usage); + ASSERT(r == 0); + return usage.ru_maxrss * KB; +} + void OS::Sleep(int64_t millis) { int64_t micros = millis * kMicrosecondsPerMillisecond; SleepMicros(micros); diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc index f8ea9ab35e9..25e36162a16 100644 --- a/runtime/vm/os_macos.cc +++ b/runtime/vm/os_macos.cc @@ -200,6 +200,14 @@ int OS::NumberOfAvailableProcessors() { return sysconf(_SC_NPROCESSORS_ONLN); } +uintptr_t OS::MaxRSS() { + struct rusage usage; + usage.ru_maxrss = 0; + int r = getrusage(RUSAGE_SELF, &usage); + ASSERT(r == 0); + return usage.ru_maxrss; +} + void OS::Sleep(int64_t millis) { int64_t micros = millis * kMicrosecondsPerMillisecond; SleepMicros(micros); diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc index 68f77f6e451..aa7e774713c 100644 --- a/runtime/vm/os_win.cc +++ b/runtime/vm/os_win.cc @@ -206,6 +206,12 @@ int OS::NumberOfAvailableProcessors() { return info.dwNumberOfProcessors; } +uintptr_t OS::MaxRSS() { + PROCESS_MEMORY_COUNTERS pmc; + GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); + return pmc.PeakWorkingSetSize; +} + void OS::Sleep(int64_t millis) { ::Sleep(millis); } diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 066354f0d59..b47a133c76a 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -109,7 +109,6 @@ const ServiceMethodDescriptor* FindMethod(const char* method_name); Dart_ServiceStreamListenCallback Service::stream_listen_callback_ = NULL; Dart_ServiceStreamCancelCallback Service::stream_cancel_callback_ = NULL; Dart_GetVMServiceAssetsArchive Service::get_service_assets_callback_ = NULL; -Dart_EmbedderInformationCallback Service::embedder_information_callback_ = NULL; // These are the set of streams known to the core VM. StreamInfo Service::vm_stream("VM"); @@ -1228,41 +1227,6 @@ void Service::SetGetServiceAssetsCallback( get_service_assets_callback_ = get_service_assets; } -void Service::SetEmbedderInformationCallback( - Dart_EmbedderInformationCallback callback) { - embedder_information_callback_ = callback; -} - -int64_t Service::CurrentRSS() { - if (embedder_information_callback_ == NULL) { - return -1; - } - Dart_EmbedderInformation info = { - 0, // version - NULL, // name - 0, // max_rss - 0 // current_rss - }; - embedder_information_callback_(&info); - ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); - return info.current_rss; -} - -int64_t Service::MaxRSS() { - if (embedder_information_callback_ == NULL) { - return -1; - } - Dart_EmbedderInformation info = { - 0, // version - NULL, // name - 0, // max_rss - 0 // current_rss - }; - embedder_information_callback_(&info); - ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); - return info.max_rss; -} - EmbedderServiceHandler* Service::FindRootEmbedderHandler(const char* name) { EmbedderServiceHandler* current = root_service_handler_head_; while (current != NULL) { @@ -3857,28 +3821,6 @@ static const MethodParameter* get_vm_params[] = { NO_ISOLATE_PARAMETER, NULL, }; -void Service::PrintJSONForEmbedderInformation(JSONObject *jsobj) { - if (embedder_information_callback_ != NULL) { - Dart_EmbedderInformation info = { - 0, // version - NULL, // name - 0, // max_rss - 0 // current_rss - }; - embedder_information_callback_(&info); - ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); - if (info.name != NULL) { - jsobj->AddProperty("_embedder", info.name); - } - if (info.max_rss > 0) { - jsobj->AddProperty64("_maxRSS", info.max_rss); - } - if (info.max_rss > 0) { - jsobj->AddProperty64("_currentRSS", info.current_rss); - } - } -} - void Service::PrintJSONForVM(JSONStream* js, bool ref) { JSONObject jsobj(js); jsobj.AddProperty("type", (ref ? "@VM" : "VM")); @@ -3894,10 +3836,10 @@ void Service::PrintJSONForVM(JSONStream* js, bool ref) { jsobj.AddProperty64("_nativeZoneMemoryUsage", ApiNativeScope::current_memory_usage()); jsobj.AddProperty64("pid", OS::ProcessId()); + jsobj.AddProperty64("_maxRSS", OS::MaxRSS()); jsobj.AddPropertyTimeMillis( "startTime", OS::GetCurrentTimeMillis() - Dart::UptimeMillis()); MallocHooks::PrintToJSONObject(&jsobj); - PrintJSONForEmbedderInformation(&jsobj); // Construct the isolate list. { JSONArray jsarr(&jsobj, "isolates"); diff --git a/runtime/vm/service.h b/runtime/vm/service.h index b6704cbe31a..0d9aa39e5a6 100644 --- a/runtime/vm/service.h +++ b/runtime/vm/service.h @@ -25,7 +25,6 @@ class GrowableObjectArray; class Instance; class Isolate; class JSONStream; -class JSONObject; class Object; class RawInstance; class RawError; @@ -101,9 +100,6 @@ class Service : public AllStatic { Dart_ServiceRequestCallback callback, void* user_data); - static void SetEmbedderInformationCallback( - Dart_EmbedderInformationCallback callback); - static void SetEmbedderStreamCallbacks( Dart_ServiceStreamListenCallback listen_callback, Dart_ServiceStreamCancelCallback cancel_callback); @@ -167,14 +163,10 @@ class Service : public AllStatic { return stream_cancel_callback_; } - static void PrintJSONForEmbedderInformation(JSONObject *jsobj); static void PrintJSONForVM(JSONStream* js, bool ref); static void CheckForPause(Isolate* isolate, JSONStream* stream); - static int64_t CurrentRSS(); - static int64_t MaxRSS(); - private: static RawError* InvokeMethod(Isolate* isolate, const Array& message, @@ -217,7 +209,6 @@ class Service : public AllStatic { static Dart_ServiceStreamListenCallback stream_listen_callback_; static Dart_ServiceStreamCancelCallback stream_cancel_callback_; static Dart_GetVMServiceAssetsArchive get_service_assets_callback_; - static Dart_EmbedderInformationCallback embedder_information_callback_; static bool needs_isolate_events_; static bool needs_debug_events_;