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

Side by Side Diff: runtime/bin/process_linux.cc

Issue 2999933002: Revert "Add current rss and embedder name to Observatory" (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/include/dart_tools_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_LINUX) 8 #if defined(HOST_OS_LINUX)
9 9
10 #include "bin/process.h" 10 #include "bin/process.h"
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 } 853 }
854 854
855 void Process::TerminateExitCodeHandler() { 855 void Process::TerminateExitCodeHandler() {
856 ExitCodeHandler::TerminateExitCodeThread(); 856 ExitCodeHandler::TerminateExitCodeThread();
857 } 857 }
858 858
859 intptr_t Process::CurrentProcessId() { 859 intptr_t Process::CurrentProcessId() {
860 return static_cast<intptr_t>(getpid()); 860 return static_cast<intptr_t>(getpid());
861 } 861 }
862 862
863 static void SaveErrorAndClose(FILE* file) {
864 int actual_errno = errno;
865 fclose(file);
866 errno = actual_errno;
867 }
868
869 int64_t Process::CurrentRSS() { 863 int64_t Process::CurrentRSS() {
870 // The second value in /proc/self/statm is the current RSS in pages. 864 // The second value in /proc/self/statm is the current RSS in pages.
871 // It is not possible to use getrusage() because the interested fields are not 865 File* statm = File::Open("/proc/self/statm", File::kRead);
872 // implemented by the linux kernel.
873 FILE* statm = fopen("/proc/self/statm", "r");
874 if (statm == NULL) { 866 if (statm == NULL) {
875 return -1; 867 return -1;
876 } 868 }
877 int64_t current_rss_pages = 0; 869 RefCntReleaseScope<File> releaser(statm);
878 int matches = fscanf(statm, "%*s%" Pd64 "", &current_rss_pages); 870 const intptr_t statm_length = 1 * KB;
879 if (matches != 1) { 871 void* buffer = reinterpret_cast<void*>(Dart_ScopeAllocate(statm_length));
880 SaveErrorAndClose(statm); 872 const intptr_t statm_read = statm->Read(buffer, statm_length);
873 if (statm_read <= 0) {
881 return -1; 874 return -1;
882 } 875 }
883 fclose(statm); 876 int64_t current_rss_pages = 0;
877 int matches = sscanf(reinterpret_cast<char*>(buffer), "%*s%" Pd64 "",
878 &current_rss_pages);
879 if (matches != 1) {
880 return -1;
881 }
884 return current_rss_pages * getpagesize(); 882 return current_rss_pages * getpagesize();
885 } 883 }
886 884
887 int64_t Process::MaxRSS() { 885 int64_t Process::MaxRSS() {
888 struct rusage usage; 886 struct rusage usage;
889 usage.ru_maxrss = 0; 887 usage.ru_maxrss = 0;
890 int r = getrusage(RUSAGE_SELF, &usage); 888 int r = getrusage(RUSAGE_SELF, &usage);
891 if (r < 0) { 889 if (r < 0) {
892 return -1; 890 return -1;
893 } 891 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 sigaction(signal, &act, NULL); 997 sigaction(signal, &act, NULL);
1000 } 998 }
1001 } 999 }
1002 1000
1003 } // namespace bin 1001 } // namespace bin
1004 } // namespace dart 1002 } // namespace dart
1005 1003
1006 #endif // defined(HOST_OS_LINUX) 1004 #endif // defined(HOST_OS_LINUX)
1007 1005
1008 #endif // !defined(DART_IO_DISABLED) 1006 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/process_android.cc ('k') | runtime/include/dart_tools_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698