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

Unified Diff: runtime/vm/service.cc

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
« no previous file with comments | « runtime/vm/service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index b47a133c76ae4f299214cd2ed228162fadc8393f..066354f0d59c8066470953dd4e2642609acece5f 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -109,6 +109,7 @@ 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");
@@ -1227,6 +1228,41 @@ 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) {
@@ -3821,6 +3857,28 @@ 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"));
@@ -3836,10 +3894,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");
« no previous file with comments | « runtime/vm/service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698