Revert "Add current rss and embedder name to Observatory"

This reverts commit ce736d3ef0.

TBR=zra@google.com

Review-Url: https://codereview.chromium.org/2999933002 .
This commit is contained in:
Carlo Bernaschina 2017-08-14 15:45:08 -07:00
parent 0908a611f4
commit 2f5a59e658
29 changed files with 123 additions and 335 deletions

View file

@ -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)) {

View file

@ -859,27 +859,25 @@ intptr_t Process::CurrentProcessId() {
return static_cast<intptr_t>(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 "", &current_rss_pages);
if (matches != 1) {
SaveErrorAndClose(statm);
RefCntReleaseScope<File> releaser(statm);
const intptr_t statm_length = 1 * KB;
void* buffer = reinterpret_cast<void*>(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<char*>(buffer), "%*s%" Pd64 "",
&current_rss_pages);
if (matches != 1) {
return -1;
}
fclose(statm);
return current_rss_pages * getpagesize();
}

View file

@ -860,27 +860,25 @@ intptr_t Process::CurrentProcessId() {
return static_cast<intptr_t>(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 "", &current_rss_pages);
if (matches != 1) {
SaveErrorAndClose(statm);
RefCntReleaseScope<File> releaser(statm);
const intptr_t statm_length = 1 * KB;
void* buffer = reinterpret_cast<void*>(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<char*>(buffer), "%*s%" Pd64 "",
&current_rss_pages);
if (matches != 1) {
return -1;
}
fclose(statm);
return current_rss_pages * getpagesize();
}

View file

@ -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

View file

@ -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';

View file

@ -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';

View file

@ -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) {

View file

@ -41,19 +41,17 @@ class MemoryDashboardElement extends HtmlElement implements Renderable {
Stream<RenderedEvent<MemoryDashboardElement>> 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)]),

View file

@ -41,8 +41,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
Stream<IsolateSelectedEvent> 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(<int>[0, 0]);
_vmSamples.add(0);
_isolateUsedSamples.add([]);
_isolateFreeSamples.add([]);
sample = sample.add(_period);
}
_ts.add(now);
_vmSamples.add(<int>[0, 0]);
_vmSamples.add(0);
_isolateUsedSamples.add([]);
_isolateFreeSamples.add([]);
}
@ -112,7 +109,7 @@ class MemoryGraphElement extends HtmlElement implements Renderable {
}
final List<DateTime> _ts = <DateTime>[];
final List<List<int>> _vmSamples = <List<int>>[];
final List<int> _vmSamples = <int>[];
final List<M.IsolateRef> _seenIsolates = <M.IsolateRef>[];
final List<List<int>> _isolateUsedSamples = <List<int>>[];
final List<List<int>> _isolateFreeSamples = <List<int>>[];
@ -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<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();
@ -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 <int>[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(<int>[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(<int>[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;

View file

@ -34,7 +34,6 @@ class VMViewElement extends HtmlElement implements Renderable {
Stream<RenderedEvent<VMViewElement>> 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 = <HtmlElement>[
..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()

View file

@ -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.
///

View file

@ -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<VM> get(VMRef ref);
}

View file

@ -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<M.VM> get(M.VMRef ref) async {
S.VM vm = ref as S.VM;
assert(vm != null);
await vm.reload();
return vm;
}
}

View file

@ -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'];

View file

@ -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',

View file

@ -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<M.IsolateRef> 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 []});
}

View file

@ -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));
},
];

View file

@ -702,7 +702,7 @@ BENCHMARK(LargeMap) {
}
BENCHMARK_MEMORY(InitialRSS) {
benchmark->set_score(Service::MaxRSS());
benchmark->set_score(OS::MaxRSS());
}
} // namespace dart

View file

@ -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) {

View file

@ -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) \

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);
}

View file

@ -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);

View file

@ -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);

View file

@ -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);
}

View file

@ -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");

View file

@ -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_;