#ifdef ENABLE_LOGGING_AND_PROFILING
void HeapProfiler::WriteSample() {
LOG(HeapSampleBeginEvent("Heap", "allocated"));
+ LOG(HeapSampleStats(
+ "Heap", "allocated", Heap::Capacity(), Heap::SizeOfObjects()));
HistogramInfo info[LAST_TYPE+1];
#define DEF_TYPE_NAME(name) info[name].set_name(#name);
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_gc) return;
LogMessageBuilder msg;
- msg.Append("heap-sample-begin,\"%s\",\"%s\"", space, kind);
- uint32_t sec, usec;
- if (OS::GetUserTime(&sec, &usec) != -1) {
- msg.Append(",%d,%d", sec, usec);
- }
- msg.Append('\n');
+ // Using non-relative system time in order to be able to synchronize with
+ // external memory profiling events (e.g. DOM memory size).
+ msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n",
+ space, kind, OS::TimeCurrentMillis());
+ msg.WriteToLogFile();
+#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();
#endif
}
static void HeapSampleBeginEvent(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 HeapSampleStats(const char* space, const char* kind,
+ int capacity, int used);
static void SharedLibraryEvent(const char* library_path,
uintptr_t start,
import csv, sys, time
def process_logfile(filename):
+ first_call_time = None
sample_time = 0.0
sampling = False
try:
for row in logreader:
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)
sampling = True
elif row[0] == 'heap-sample-end' and row[1] == 'Heap':