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

Unified Diff: runtime/vm/service.cc

Issue 2996803002: Add current rss and embedder name to Observatory (Closed)
Patch Set: Refactoring 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..d988b798887cab47a61594432d7572e36637310f 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) {
@@ -3836,7 +3872,25 @@ void Service::PrintJSONForVM(JSONStream* js, bool ref) {
jsobj.AddProperty64("_nativeZoneMemoryUsage",
ApiNativeScope::current_memory_usage());
jsobj.AddProperty64("pid", OS::ProcessId());
- jsobj.AddProperty64("_maxRSS", OS::MaxRSS());
+ if (embedder_information_callback_ != NULL) {
zra 2017/08/14 18:26:32 Possible cleanup: Pull this out into e.g. Service:
cbernaschina 2017/08/14 20:07:40 Done.
+ 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);
+ }
+ }
jsobj.AddPropertyTimeMillis(
"startTime", OS::GetCurrentTimeMillis() - Dart::UptimeMillis());
MallocHooks::PrintToJSONObject(&jsobj);
« 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