Commit ba559651 authored by hpayer's avatar hpayer Committed by Commit bot

Print PID and isolate address in gc traces.

Note, that it also moves incremental marking traces behind the --trace-incremental-marking flag.

Other PrintF's of the GC should be moved as well to PrintPIDAndIsolate.

BUG=

Review URL: https://codereview.chromium.org/1109133002

Cr-Commit-Position: refs/heads/master@{#28135}
parent 58b0023f
...@@ -276,7 +276,8 @@ void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { ...@@ -276,7 +276,8 @@ void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) {
void GCTracer::Print() const { void GCTracer::Print() const {
PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); PrintIsolate(heap_->isolate(), "%8.0f ms: ",
heap_->isolate()->time_millis_since_init());
PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", current_.TypeName(false), PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", current_.TypeName(false),
static_cast<double>(current_.start_object_size) / MB, static_cast<double>(current_.start_object_size) / MB,
...@@ -319,7 +320,8 @@ void GCTracer::Print() const { ...@@ -319,7 +320,8 @@ void GCTracer::Print() const {
void GCTracer::PrintNVP() const { void GCTracer::PrintNVP() const {
PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); PrintIsolate(heap_->isolate(), "[I:%p] %8.0f ms: ", heap_->isolate(),
heap_->isolate()->time_millis_since_init());
double duration = current_.end_time - current_.start_time; double duration = current_.end_time - current_.start_time;
double spent_in_mutator = current_.start_time - previous_.end_time; double spent_in_mutator = current_.start_time - previous_.end_time;
......
...@@ -317,56 +317,58 @@ void Heap::ReportStatisticsBeforeGC() { ...@@ -317,56 +317,58 @@ void Heap::ReportStatisticsBeforeGC() {
void Heap::PrintShortHeapStatistics() { void Heap::PrintShortHeapStatistics() {
if (!FLAG_trace_gc_verbose) return; if (!FLAG_trace_gc_verbose) return;
PrintPID("Memory allocator, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "Memory allocator, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX "d KB\n", ", available: %6" V8_PTR_PREFIX "d KB\n",
isolate_->memory_allocator()->Size() / KB, isolate_->memory_allocator()->Size() / KB,
isolate_->memory_allocator()->Available() / KB); isolate_->memory_allocator()->Available() / KB);
PrintPID("New space, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "New space, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX ", available: %6" V8_PTR_PREFIX
"d KB" "d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n", ", committed: %6" V8_PTR_PREFIX "d KB\n",
new_space_.Size() / KB, new_space_.Available() / KB, new_space_.Size() / KB, new_space_.Available() / KB,
new_space_.CommittedMemory() / KB); new_space_.CommittedMemory() / KB);
PrintPID("Old space, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "Old space, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX ", available: %6" V8_PTR_PREFIX
"d KB" "d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n", ", committed: %6" V8_PTR_PREFIX "d KB\n",
old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, old_space_->SizeOfObjects() / KB, old_space_->Available() / KB,
old_space_->CommittedMemory() / KB); old_space_->CommittedMemory() / KB);
PrintPID("Code space, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "Code space, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX ", available: %6" V8_PTR_PREFIX
"d KB" "d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n", ", committed: %6" V8_PTR_PREFIX "d KB\n",
code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, code_space_->SizeOfObjects() / KB, code_space_->Available() / KB,
code_space_->CommittedMemory() / KB); code_space_->CommittedMemory() / KB);
PrintPID("Map space, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "Map space, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX ", available: %6" V8_PTR_PREFIX
"d KB" "d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n", ", committed: %6" V8_PTR_PREFIX "d KB\n",
map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, map_space_->SizeOfObjects() / KB, map_space_->Available() / KB,
map_space_->CommittedMemory() / KB); map_space_->CommittedMemory() / KB);
PrintPID("Large object space, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "Large object space, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX ", available: %6" V8_PTR_PREFIX
"d KB" "d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n", ", committed: %6" V8_PTR_PREFIX "d KB\n",
lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB,
lo_space_->CommittedMemory() / KB); lo_space_->CommittedMemory() / KB);
PrintPID("All spaces, used: %6" V8_PTR_PREFIX PrintIsolate(isolate_, "All spaces, used: %6" V8_PTR_PREFIX
"d KB" "d KB"
", available: %6" V8_PTR_PREFIX ", available: %6" V8_PTR_PREFIX
"d KB" "d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n", ", committed: %6" V8_PTR_PREFIX "d KB\n",
this->SizeOfObjects() / KB, this->Available() / KB, this->SizeOfObjects() / KB, this->Available() / KB,
this->CommittedMemory() / KB); this->CommittedMemory() / KB);
PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n", PrintIsolate(
static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB)); isolate_, "External memory reported: %6" V8_PTR_PREFIX "d KB\n",
PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_); static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB));
PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n",
total_gc_time_ms_);
} }
...@@ -4708,7 +4710,7 @@ bool Heap::IdleNotification(double deadline_in_seconds) { ...@@ -4708,7 +4710,7 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
if ((FLAG_trace_idle_notification && action.type > DO_NOTHING) || if ((FLAG_trace_idle_notification && action.type > DO_NOTHING) ||
FLAG_trace_idle_notification_verbose) { FLAG_trace_idle_notification_verbose) {
PrintPID("%8.0f ms: ", isolate()->time_millis_since_init()); PrintIsolate(isolate_, "%8.0f ms: ", isolate()->time_millis_since_init());
PrintF( PrintF(
"Idle notification: requested idle time %.2f ms, used idle time %.2f " "Idle notification: requested idle time %.2f ms, used idle time %.2f "
"ms, deadline usage %.2f ms [", "ms, deadline usage %.2f ms [",
...@@ -5080,8 +5082,9 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size, ...@@ -5080,8 +5082,9 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
if (max_semi_space_size_ > reserved_semispace_size_) { if (max_semi_space_size_ > reserved_semispace_size_) {
max_semi_space_size_ = reserved_semispace_size_; max_semi_space_size_ = reserved_semispace_size_;
if (FLAG_trace_gc) { if (FLAG_trace_gc) {
PrintPID("Max semi-space size cannot be more than %d kbytes\n", PrintIsolate(isolate_,
reserved_semispace_size_ >> 10); "Max semi-space size cannot be more than %d kbytes\n",
reserved_semispace_size_ >> 10);
} }
} }
} else { } else {
...@@ -5108,10 +5111,10 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size, ...@@ -5108,10 +5111,10 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
if (initial_semispace_size > max_semi_space_size_) { if (initial_semispace_size > max_semi_space_size_) {
initial_semispace_size_ = max_semi_space_size_; initial_semispace_size_ = max_semi_space_size_;
if (FLAG_trace_gc) { if (FLAG_trace_gc) {
PrintPID( PrintIsolate(isolate_,
"Min semi-space size cannot be more than the maximum " "Min semi-space size cannot be more than the maximum "
"semi-space size of %d MB\n", "semi-space size of %d MB\n",
max_semi_space_size_ / MB); max_semi_space_size_ / MB);
} }
} else { } else {
initial_semispace_size_ = initial_semispace_size; initial_semispace_size_ = initial_semispace_size;
...@@ -5125,18 +5128,18 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size, ...@@ -5125,18 +5128,18 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
if (target_semispace_size < initial_semispace_size_) { if (target_semispace_size < initial_semispace_size_) {
target_semispace_size_ = initial_semispace_size_; target_semispace_size_ = initial_semispace_size_;
if (FLAG_trace_gc) { if (FLAG_trace_gc) {
PrintPID( PrintIsolate(isolate_,
"Target semi-space size cannot be less than the minimum " "Target semi-space size cannot be less than the minimum "
"semi-space size of %d MB\n", "semi-space size of %d MB\n",
initial_semispace_size_ / MB); initial_semispace_size_ / MB);
} }
} else if (target_semispace_size > max_semi_space_size_) { } else if (target_semispace_size > max_semi_space_size_) {
target_semispace_size_ = max_semi_space_size_; target_semispace_size_ = max_semi_space_size_;
if (FLAG_trace_gc) { if (FLAG_trace_gc) {
PrintPID( PrintIsolate(isolate_,
"Target semi-space size cannot be less than the maximum " "Target semi-space size cannot be less than the maximum "
"semi-space size of %d MB\n", "semi-space size of %d MB\n",
max_semi_space_size_ / MB); max_semi_space_size_ / MB);
} }
} else { } else {
target_semispace_size_ = target_semispace_size; target_semispace_size_ = target_semispace_size;
...@@ -6317,8 +6320,9 @@ static base::LazyMutex object_stats_mutex = LAZY_MUTEX_INITIALIZER; ...@@ -6317,8 +6320,9 @@ static base::LazyMutex object_stats_mutex = LAZY_MUTEX_INITIALIZER;
void Heap::TraceObjectStat(const char* name, int count, int size, double time) { void Heap::TraceObjectStat(const char* name, int count, int size, double time) {
PrintPID("heap:%p, time:%f, gc:%d, type:%s, count:%d, size:%d\n", PrintIsolate(isolate_,
static_cast<void*>(this), time, ms_count_, name, count, size); "heap:%p, time:%f, gc:%d, type:%s, count:%d, size:%d\n",
static_cast<void*>(this), time, ms_count_, name, count, size);
} }
......
...@@ -96,8 +96,10 @@ void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj, ...@@ -96,8 +96,10 @@ void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj,
// as the program mutates the heap faster than we can incrementally // as the program mutates the heap faster than we can incrementally
// trace it. In this case we switch to non-incremental marking in // trace it. In this case we switch to non-incremental marking in
// order to finish off this marking phase. // order to finish off this marking phase.
if (FLAG_trace_gc) { if (FLAG_trace_incremental_marking) {
PrintPID("Hurrying incremental marking because of lack of progress\n"); PrintIsolate(
heap()->isolate(),
"Hurrying incremental marking because of lack of progress\n");
} }
marking_speed_ = kMaxMarkingSpeed; marking_speed_ = kMaxMarkingSpeed;
} }
......
...@@ -431,6 +431,21 @@ void IncrementalMarking::ActivateGeneratedStub(Code* stub) { ...@@ -431,6 +431,21 @@ void IncrementalMarking::ActivateGeneratedStub(Code* stub) {
} }
void IncrementalMarking::NotifyOfHighPromotionRate() {
if (IsMarking()) {
if (marking_speed_ < kFastMarking) {
if (FLAG_trace_gc) {
PrintIsolate(heap()->isolate(),
"Increasing marking speed to %d "
"due to high promotion rate\n",
static_cast<int>(kFastMarking));
}
marking_speed_ = kFastMarking;
}
}
}
static void PatchIncrementalMarkingRecordWriteStubs( static void PatchIncrementalMarkingRecordWriteStubs(
Heap* heap, RecordWriteStub::Mode mode) { Heap* heap, RecordWriteStub::Mode mode) {
UnseededNumberDictionary* stubs = heap->code_stubs(); UnseededNumberDictionary* stubs = heap->code_stubs();
...@@ -827,9 +842,9 @@ void IncrementalMarking::SpeedUp() { ...@@ -827,9 +842,9 @@ void IncrementalMarking::SpeedUp() {
bool speed_up = false; bool speed_up = false;
if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) {
if (FLAG_trace_gc) { if (FLAG_trace_incremental_marking) {
PrintPID("Speed up marking after %d steps\n", PrintIsolate(heap()->isolate(), "Speed up marking after %d steps\n",
static_cast<int>(kMarkingSpeedAccellerationInterval)); static_cast<int>(kMarkingSpeedAccellerationInterval));
} }
speed_up = true; speed_up = true;
} }
...@@ -843,7 +858,9 @@ void IncrementalMarking::SpeedUp() { ...@@ -843,7 +858,9 @@ void IncrementalMarking::SpeedUp() {
if (space_left_is_very_small || if (space_left_is_very_small ||
only_1_nth_of_space_that_was_available_still_left) { only_1_nth_of_space_that_was_available_still_left) {
if (FLAG_trace_gc) PrintPID("Speed up marking because of low space left\n"); if (FLAG_trace_incremental_marking)
PrintIsolate(heap()->isolate(),
"Speed up marking because of low space left\n");
speed_up = true; speed_up = true;
} }
...@@ -853,8 +870,9 @@ void IncrementalMarking::SpeedUp() { ...@@ -853,8 +870,9 @@ void IncrementalMarking::SpeedUp() {
old_generation_space_used_at_start_of_incremental_); old_generation_space_used_at_start_of_incremental_);
if (size_of_old_space_multiplied_by_n_during_marking) { if (size_of_old_space_multiplied_by_n_during_marking) {
speed_up = true; speed_up = true;
if (FLAG_trace_gc) { if (FLAG_trace_incremental_marking) {
PrintPID("Speed up marking because of heap size increase\n"); PrintIsolate(heap()->isolate(),
"Speed up marking because of heap size increase\n");
} }
} }
...@@ -866,23 +884,26 @@ void IncrementalMarking::SpeedUp() { ...@@ -866,23 +884,26 @@ void IncrementalMarking::SpeedUp() {
// We try to scan at at least twice the speed that we are allocating. // We try to scan at at least twice the speed that we are allocating.
if (promoted_during_marking > bytes_scanned_ / 2 + scavenge_slack + delay) { if (promoted_during_marking > bytes_scanned_ / 2 + scavenge_slack + delay) {
if (FLAG_trace_gc) { if (FLAG_trace_incremental_marking) {
PrintPID("Speed up marking because marker was not keeping up\n"); PrintIsolate(heap()->isolate(),
"Speed up marking because marker was not keeping up\n");
} }
speed_up = true; speed_up = true;
} }
if (speed_up) { if (speed_up) {
if (state_ != MARKING) { if (state_ != MARKING) {
if (FLAG_trace_gc) { if (FLAG_trace_incremental_marking) {
PrintPID("Postponing speeding up marking until marking starts\n"); PrintIsolate(heap()->isolate(),
"Postponing speeding up marking until marking starts\n");
} }
} else { } else {
marking_speed_ += kMarkingSpeedAccelleration; marking_speed_ += kMarkingSpeedAccelleration;
marking_speed_ = static_cast<int>( marking_speed_ = static_cast<int>(
Min(kMaxMarkingSpeed, static_cast<intptr_t>(marking_speed_ * 1.3))); Min(kMaxMarkingSpeed, static_cast<intptr_t>(marking_speed_ * 1.3)));
if (FLAG_trace_gc) { if (FLAG_trace_incremental_marking) {
PrintPID("Marking speed increased to %d\n", marking_speed_); PrintIsolate(heap()->isolate(), "Marking speed increased to %d\n",
marking_speed_);
} }
} }
} }
......
...@@ -169,19 +169,7 @@ class IncrementalMarking { ...@@ -169,19 +169,7 @@ class IncrementalMarking {
void ActivateGeneratedStub(Code* stub); void ActivateGeneratedStub(Code* stub);
void NotifyOfHighPromotionRate() { void NotifyOfHighPromotionRate();
if (IsMarking()) {
if (marking_speed_ < kFastMarking) {
if (FLAG_trace_gc) {
PrintPID(
"Increasing marking speed to %d "
"due to high promotion rate\n",
static_cast<int>(kFastMarking));
}
marking_speed_ = kFastMarking;
}
}
}
void EnterNoMarkingScope() { no_marking_scope_depth_++; } void EnterNoMarkingScope() { no_marking_scope_depth_++; }
......
...@@ -114,6 +114,15 @@ void PrintPID(const char* format, ...) { ...@@ -114,6 +114,15 @@ void PrintPID(const char* format, ...) {
} }
void PrintIsolate(void* isolate, const char* format, ...) {
base::OS::Print("[%d:%p] ", base::OS::GetCurrentProcessId(), isolate);
va_list arguments;
va_start(arguments, format);
base::OS::VPrint(format, arguments);
va_end(arguments);
}
int SNPrintF(Vector<char> str, const char* format, ...) { int SNPrintF(Vector<char> str, const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
......
...@@ -1140,6 +1140,9 @@ void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...); ...@@ -1140,6 +1140,9 @@ void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...);
// Prepends the current process ID to the output. // Prepends the current process ID to the output.
void PRINTF_CHECKING PrintPID(const char* format, ...); void PRINTF_CHECKING PrintPID(const char* format, ...);
// Prepends the current process ID and given isolate pointer to the output.
void PrintIsolate(void* isolate, const char* format, ...);
// Safe formatting print. Ensures that str is always null-terminated. // Safe formatting print. Ensures that str is always null-terminated.
// Returns the number of chars written, or -1 if output was truncated. // Returns the number of chars written, or -1 if output was truncated.
int FPRINTF_CHECKING SNPrintF(Vector<char> str, const char* format, ...); int FPRINTF_CHECKING SNPrintF(Vector<char> str, const char* format, ...);
......
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