Heap profiling: add logging of heap memory stats (capacity, used) under 'log-gc' flag.

Also changed time reporting to system time to be able to get synchronized with other memory (e.g. DOM) size status.

Review URL: http://codereview.chromium.org/155764

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2509 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ab59ea5a
...@@ -3406,6 +3406,8 @@ void HeapProfiler::CollectStats(HeapObject* obj, HistogramInfo* info) { ...@@ -3406,6 +3406,8 @@ void HeapProfiler::CollectStats(HeapObject* obj, HistogramInfo* info) {
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
void HeapProfiler::WriteSample() { void HeapProfiler::WriteSample() {
LOG(HeapSampleBeginEvent("Heap", "allocated")); LOG(HeapSampleBeginEvent("Heap", "allocated"));
LOG(HeapSampleStats(
"Heap", "allocated", Heap::Capacity(), Heap::SizeOfObjects()));
HistogramInfo info[LAST_TYPE+1]; HistogramInfo info[LAST_TYPE+1];
#define DEF_TYPE_NAME(name) info[name].set_name(#name); #define DEF_TYPE_NAME(name) info[name].set_name(#name);
......
...@@ -843,12 +843,22 @@ void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { ...@@ -843,12 +843,22 @@ void Logger::HeapSampleBeginEvent(const char* space, const char* kind) {
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_gc) return; if (!Log::IsEnabled() || !FLAG_log_gc) return;
LogMessageBuilder msg; LogMessageBuilder msg;
msg.Append("heap-sample-begin,\"%s\",\"%s\"", space, kind); // Using non-relative system time in order to be able to synchronize with
uint32_t sec, usec; // external memory profiling events (e.g. DOM memory size).
if (OS::GetUserTime(&sec, &usec) != -1) { msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n",
msg.Append(",%d,%d", sec, usec); space, kind, OS::TimeCurrentMillis());
} msg.WriteToLogFile();
msg.Append('\n'); #endif
}
void Logger::HeapSampleStats(const char* space, const char* kind,
int capacity, int used) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_gc) return;
LogMessageBuilder msg;
msg.Append("heap-sample-stats,\"%s\",\"%s\",%d,%d\n",
space, kind, capacity, used);
msg.WriteToLogFile(); msg.WriteToLogFile();
#endif #endif
} }
......
...@@ -219,6 +219,8 @@ class Logger { ...@@ -219,6 +219,8 @@ class Logger {
static void HeapSampleBeginEvent(const char* space, const char* kind); static void HeapSampleBeginEvent(const char* space, const char* kind);
static void HeapSampleEndEvent(const char* space, const char* kind); static void HeapSampleEndEvent(const char* space, const char* kind);
static void HeapSampleItemEvent(const char* type, int number, int bytes); static void HeapSampleItemEvent(const char* type, int number, int bytes);
static void HeapSampleStats(const char* space, const char* kind,
int capacity, int used);
static void SharedLibraryEvent(const char* library_path, static void SharedLibraryEvent(const char* library_path,
uintptr_t start, uintptr_t start,
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
import csv, sys, time import csv, sys, time
def process_logfile(filename): def process_logfile(filename):
first_call_time = None
sample_time = 0.0 sample_time = 0.0
sampling = False sampling = False
try: try:
...@@ -53,7 +54,10 @@ def process_logfile(filename): ...@@ -53,7 +54,10 @@ def process_logfile(filename):
for row in logreader: for row in logreader:
if row[0] == 'heap-sample-begin' and row[1] == 'Heap': if row[0] == 'heap-sample-begin' and row[1] == 'Heap':
sample_time = float(row[3]) + float(row[4])/1000000.0 sample_time = float(row[3])/1000.0
if first_call_time == None:
first_call_time = sample_time
sample_time -= first_call_time
print('BEGIN_SAMPLE %.2f' % sample_time) print('BEGIN_SAMPLE %.2f' % sample_time)
sampling = True sampling = True
elif row[0] == 'heap-sample-end' and row[1] == 'Heap': elif row[0] == 'heap-sample-end' and row[1] == 'Heap':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment