Commit bcf4c66b authored by ulan's avatar ulan Committed by Commit bot

Make incremental marking tracing format consistent with GC tracing.

Now incremental marking tracing outputs isolate and timestamp:

[41894:0x21efec0]    17253 ms: [IncrementalMarking] Start (old space step)

This patch also adds walltime duration of incremental marking to GC trace output.

BUG=

Review-Url: https://codereview.chromium.org/2293883002
Cr-Commit-Position: refs/heads/master@{#39016}
parent f7bc1fc7
......@@ -228,9 +228,10 @@ void GCTracer::MergeBaseline(const Event& baseline) {
void GCTracer::Stop(GarbageCollector collector) {
start_counter_--;
if (start_counter_ != 0) {
PrintIsolate(heap_->isolate(), "[Finished reentrant %s during %s.]\n",
collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
current_.TypeName(false));
heap_->isolate()->PrintWithTimestamp(
"[Finished reentrant %s during %s.]\n",
collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
current_.TypeName(false));
return;
}
......@@ -408,23 +409,15 @@ void GCTracer::Print() const {
const size_t kIncrementalStatsSize = 128;
char incremental_buffer[kIncrementalStatsSize] = {0};
if (current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps > 0) {
if (current_.type == Event::SCAVENGER) {
base::OS::SNPrintF(
incremental_buffer, kIncrementalStatsSize,
" (+ %.1f ms in %d steps since last GC)",
current_.scopes[Scope::MC_INCREMENTAL],
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps);
} else {
base::OS::SNPrintF(
incremental_buffer, kIncrementalStatsSize,
" (+ %.1f ms in %d steps since start of marking, "
"biggest step %.1f ms)",
current_.scopes[Scope::MC_INCREMENTAL],
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL]
.longest_step);
}
if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) {
base::OS::SNPrintF(
incremental_buffer, kIncrementalStatsSize,
" (+ %.1f ms in %d steps since start of marking, "
"biggest step %.1f ms, walltime since start of marking %.f ms)",
current_.scopes[Scope::MC_INCREMENTAL],
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].longest_step,
current_.end_time - incremental_marking_start_time_);
}
// Avoid PrintF as Output also appends the string to the tracing ring buffer
......@@ -453,11 +446,16 @@ void GCTracer::PrintNVP() const {
intptr_t allocated_since_last_gc =
current_.start_object_size - previous_.end_object_size;
double incremental_walltime_duration = 0;
if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) {
incremental_walltime_duration =
current_.end_time - incremental_marking_start_time_;
}
switch (current_.type) {
case Event::SCAVENGER:
PrintIsolate(
heap_->isolate(),
"%8.0f ms: "
heap_->isolate()->PrintWithTimestamp(
"pause=%.1f "
"mutator=%.1f "
"gc=%s "
......@@ -498,9 +496,8 @@ void GCTracer::PrintNVP() const {
"semi_space_copy_rate=%.1f%% "
"new_space_allocation_throughput=%.1f "
"context_disposal_rate=%.1f\n",
heap_->isolate()->time_millis_since_init(), duration,
spent_in_mutator, current_.TypeName(true), current_.reduce_memory,
current_.scopes[Scope::SCAVENGER_SCAVENGE],
duration, spent_in_mutator, current_.TypeName(true),
current_.reduce_memory, current_.scopes[Scope::SCAVENGER_SCAVENGE],
current_.scopes[Scope::SCAVENGER_OLD_TO_NEW_POINTERS],
current_.scopes[Scope::SCAVENGER_WEAK],
current_.scopes[Scope::SCAVENGER_ROOTS],
......@@ -527,9 +524,7 @@ void GCTracer::PrintNVP() const {
break;
case Event::MARK_COMPACTOR:
case Event::INCREMENTAL_MARK_COMPACTOR:
PrintIsolate(
heap_->isolate(),
"%8.0f ms: "
heap_->isolate()->PrintWithTimestamp(
"pause=%.1f "
"mutator=%.1f "
"gc=%s "
......@@ -589,6 +584,7 @@ void GCTracer::PrintNVP() const {
"incremental_longest_step=%.1f "
"incremental_steps_count=%d "
"incremental_marking_throughput=%.f "
"incremental_walltime_duration=%.f "
"total_size_before=%" V8PRIdPTR
" "
"total_size_after=%" V8PRIdPTR
......@@ -613,9 +609,8 @@ void GCTracer::PrintNVP() const {
"new_space_allocation_throughput=%.1f "
"context_disposal_rate=%.1f "
"compaction_speed=%.f\n",
heap_->isolate()->time_millis_since_init(), duration,
spent_in_mutator, current_.TypeName(true), current_.reduce_memory,
current_.scopes[Scope::MC_CLEAR],
duration, spent_in_mutator, current_.TypeName(true),
current_.reduce_memory, current_.scopes[Scope::MC_CLEAR],
current_.scopes[Scope::MC_CLEAR_CODE_FLUSH],
current_.scopes[Scope::MC_CLEAR_DEPENDENT_CODE],
current_.scopes[Scope::MC_CLEAR_GLOBAL_HANDLES],
......@@ -676,9 +671,10 @@ void GCTracer::PrintNVP() const {
.longest_step,
current_.incremental_marking_scopes[Scope::MC_INCREMENTAL].steps,
IncrementalMarkingSpeedInBytesPerMillisecond(),
current_.start_object_size, current_.end_object_size,
current_.start_holes_size, current_.end_holes_size,
allocated_since_last_gc, heap_->promoted_objects_size(),
incremental_walltime_duration, current_.start_object_size,
current_.end_object_size, current_.start_holes_size,
current_.end_holes_size, allocated_since_last_gc,
heap_->promoted_objects_size(),
heap_->semi_space_copied_object_size(),
heap_->nodes_died_in_new_space_, heap_->nodes_copied_in_new_space_,
heap_->nodes_promoted_, heap_->promotion_ratio_,
......@@ -823,5 +819,10 @@ bool GCTracer::SurvivalEventsRecorded() const {
}
void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); }
void GCTracer::NotifyIncrementalMarkingStart() {
incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs();
}
} // namespace internal
} // namespace v8
......@@ -382,6 +382,8 @@ class GCTracer {
// Discard all recorded survival events.
void ResetSurvivalEvents();
void NotifyIncrementalMarkingStart();
V8_INLINE void AddScopeSample(Scope::ScopeId scope, double duration) {
DCHECK(scope < Scope::NUMBER_OF_SCOPES);
if (scope >= Scope::FIRST_INCREMENTAL_SCOPE &&
......@@ -477,6 +479,8 @@ class GCTracer {
// all sweeping operations performed on the main thread.
double cumulative_sweeping_duration_;
double incremental_marking_start_time_;
// Timestamp and allocation counter at the last sampled allocation event.
double allocation_time_ms_;
size_t new_space_allocation_counter_bytes_;
......
......@@ -808,7 +808,7 @@ void Heap::ScheduleIdleScavengeIfNeeded(int bytes_allocated) {
void Heap::FinalizeIncrementalMarking(const char* gc_reason) {
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] (%s).\n", gc_reason);
isolate()->PrintWithTimestamp("[IncrementalMarking] (%s).\n", gc_reason);
}
HistogramTimerScope incremental_marking_scope(
......@@ -4081,10 +4081,10 @@ double Heap::YoungGenerationMutatorUtilization() {
tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects);
double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
if (FLAG_trace_mutator_utilization) {
PrintIsolate(isolate(),
"Young generation mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed);
isolate()->PrintWithTimestamp(
"Young generation mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed);
}
return result;
}
......@@ -4097,10 +4097,10 @@ double Heap::OldGenerationMutatorUtilization() {
tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
if (FLAG_trace_mutator_utilization) {
PrintIsolate(isolate(),
"Old generation mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed);
isolate()->PrintWithTimestamp(
"Old generation mutator utilization = %.3f ("
"mutator_speed=%.f, gc_speed=%.f)\n",
result, mutator_speed, gc_speed);
}
return result;
}
......@@ -4328,8 +4328,7 @@ void Heap::IdleNotificationEpilogue(GCIdleTimeAction action,
if ((FLAG_trace_idle_notification && action.type > DO_NOTHING) ||
FLAG_trace_idle_notification_verbose) {
PrintIsolate(isolate_, "%8.0f ms: ", isolate()->time_millis_since_init());
PrintF(
isolate_->PrintWithTimestamp(
"Idle notification: requested idle time %.2f ms, used idle time %.2f "
"ms, deadline usage %.2f ms [",
idle_time_in_ms, idle_time_in_ms - deadline_difference,
......@@ -5195,11 +5194,11 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
double factor = HeapGrowingFactor(gc_speed, mutator_speed);
if (FLAG_trace_gc_verbose) {
PrintIsolate(isolate_,
"Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f "
"(gc=%.f, mutator=%.f)\n",
factor, kTargetMutatorUtilization, gc_speed / mutator_speed,
gc_speed, mutator_speed);
isolate_->PrintWithTimestamp(
"Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f "
"(gc=%.f, mutator=%.f)\n",
factor, kTargetMutatorUtilization, gc_speed / mutator_speed, gc_speed,
mutator_speed);
}
if (IsMemoryConstrainedDevice()) {
......@@ -5223,10 +5222,10 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
CalculateOldGenerationAllocationLimit(factor, old_gen_size);
if (FLAG_trace_gc_verbose) {
PrintIsolate(isolate_, "Grow: old size: %" V8PRIdPTR
" KB, new limit: %" V8PRIdPTR " KB (%.1f)\n",
old_gen_size / KB, old_generation_allocation_limit_ / KB,
factor);
isolate_->PrintWithTimestamp("Grow: old size: %" V8PRIdPTR
" KB, new limit: %" V8PRIdPTR " KB (%.1f)\n",
old_gen_size / KB,
old_generation_allocation_limit_ / KB, factor);
}
}
......@@ -5238,12 +5237,12 @@ void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size,
intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size);
if (limit < old_generation_allocation_limit_) {
if (FLAG_trace_gc_verbose) {
PrintIsolate(isolate_,
"Dampen: old size: %" V8PRIdPTR " KB, old limit: %" V8PRIdPTR
" KB, "
"new limit: %" V8PRIdPTR " KB (%.1f)\n",
old_gen_size / KB, old_generation_allocation_limit_ / KB,
limit / KB, factor);
isolate_->PrintWithTimestamp(
"Dampen: old size: %" V8PRIdPTR " KB, old limit: %" V8PRIdPTR
" KB, "
"new limit: %" V8PRIdPTR " KB (%.1f)\n",
old_gen_size / KB, old_generation_allocation_limit_ / KB, limit / KB,
factor);
}
old_generation_allocation_limit_ = limit;
}
......
......@@ -6,6 +6,7 @@
#define V8_HEAP_INCREMENTAL_MARKING_INL_H_
#include "src/heap/incremental-marking.h"
#include "src/isolate.h"
namespace v8 {
namespace internal {
......@@ -33,6 +34,15 @@ void IncrementalMarking::RecordWriteIntoCode(Code* host, RelocInfo* rinfo,
}
}
void IncrementalMarking::RestartIfNotMarking() {
if (state_ == COMPLETE) {
state_ = MARKING;
if (FLAG_trace_incremental_marking) {
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Restarting (new grey objects)\n");
}
}
}
} // namespace internal
} // namespace v8
......
......@@ -471,10 +471,10 @@ 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));
heap()->isolate()->PrintWithTimestamp(
"Increasing marking speed to %d "
"due to high promotion rate\n",
static_cast<int>(kFastMarking));
}
marking_speed_ = kFastMarking;
}
......@@ -506,8 +506,9 @@ static void PatchIncrementalMarkingRecordWriteStubs(
void IncrementalMarking::Start(const char* reason) {
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Start (%s)\n",
(reason == nullptr) ? "unknown reason" : reason);
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Start (%s)\n",
(reason == nullptr) ? "unknown reason" : reason);
}
DCHECK(FLAG_incremental_marking);
DCHECK(state_ == STOPPED);
......@@ -518,6 +519,7 @@ void IncrementalMarking::Start(const char* reason) {
heap_->isolate()->counters()->gc_incremental_marking_start());
TRACE_EVENT0("v8", "V8.GCIncrementalMarkingStart");
ResetStepCounters();
heap_->tracer()->NotifyIncrementalMarkingStart();
was_activated_ = true;
......@@ -525,7 +527,8 @@ void IncrementalMarking::Start(const char* reason) {
StartMarking();
} else {
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Start sweeping.\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Start sweeping.\n");
}
state_ = SWEEPING;
}
......@@ -542,12 +545,14 @@ void IncrementalMarking::StartMarking() {
// but we cannot enable black allocation while deserializing. Hence, we
// have to delay the start of incremental marking in that case.
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Start delayed - serializer\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Start delayed - serializer\n");
}
return;
}
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Start marking\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Start marking\n");
}
is_compacting_ = !FLAG_never_compact &&
......@@ -589,7 +594,7 @@ void IncrementalMarking::StartMarking() {
// Ready to start incremental marking.
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Running\n");
heap()->isolate()->PrintWithTimestamp("[IncrementalMarking] Running\n");
}
}
......@@ -601,7 +606,8 @@ void IncrementalMarking::StartBlackAllocation() {
heap()->map_space()->MarkAllocationInfoBlack();
heap()->code_space()->MarkAllocationInfoBlack();
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Black allocation started\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Black allocation started\n");
}
}
......@@ -609,7 +615,8 @@ void IncrementalMarking::FinishBlackAllocation() {
if (black_allocation_) {
black_allocation_ = false;
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Black allocation finished\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Black allocation finished\n");
}
}
}
......@@ -779,7 +786,7 @@ void IncrementalMarking::FinalizeIncrementally() {
double delta = end - start;
heap_->tracer()->AddMarkingTime(delta);
if (FLAG_trace_incremental_marking) {
PrintF(
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Finalize incrementally round %d, "
"spent %d ms, marking progress %d.\n",
static_cast<int>(delta), incremental_marking_finalization_rounds_,
......@@ -929,7 +936,7 @@ void IncrementalMarking::Hurry() {
if (FLAG_trace_incremental_marking || FLAG_print_cumulative_gc_stat) {
start = heap_->MonotonicallyIncreasingTimeInMs();
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Hurry\n");
heap()->isolate()->PrintWithTimestamp("[IncrementalMarking] Hurry\n");
}
}
// TODO(gc) hurry can mark objects it encounters black as mutator
......@@ -941,8 +948,9 @@ void IncrementalMarking::Hurry() {
double delta = end - start;
heap_->tracer()->AddMarkingTime(delta);
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n",
static_cast<int>(delta));
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Complete (hurry), spent %d ms.\n",
static_cast<int>(delta));
}
}
}
......@@ -968,7 +976,7 @@ void IncrementalMarking::Hurry() {
void IncrementalMarking::Stop() {
if (IsStopped()) return;
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Stopping.\n");
heap()->isolate()->PrintWithTimestamp("[IncrementalMarking] Stopping.\n");
}
heap_->new_space()->RemoveAllocationObserver(&observer_);
......@@ -995,7 +1003,7 @@ void IncrementalMarking::Finalize() {
void IncrementalMarking::FinalizeMarking(CompletionAction action) {
DCHECK(!finalize_marking_completed_);
if (FLAG_trace_incremental_marking) {
PrintF(
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] requesting finalization of incremental "
"marking.\n");
}
......@@ -1015,7 +1023,8 @@ void IncrementalMarking::MarkingComplete(CompletionAction action) {
// the should-hurry flag to indicate that there can't be much work left to do.
set_should_hurry(true);
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Complete (normal).\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Complete (normal).\n");
}
request_type_ = COMPLETE_MARKING;
if (action == GC_VIA_STACK_GUARD) {
......@@ -1072,8 +1081,9 @@ void IncrementalMarking::SpeedUp() {
if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) {
if (FLAG_trace_incremental_marking) {
PrintIsolate(heap()->isolate(), "Speed up marking after %d steps\n",
static_cast<int>(kMarkingSpeedAccellerationInterval));
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Speed up marking after %d steps\n",
static_cast<int>(kMarkingSpeedAccellerationInterval));
}
speed_up = true;
}
......@@ -1088,8 +1098,8 @@ void IncrementalMarking::SpeedUp() {
if (space_left_is_very_small ||
only_1_nth_of_space_that_was_available_still_left) {
if (FLAG_trace_incremental_marking)
PrintIsolate(heap()->isolate(),
"Speed up marking because of low space left\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Speed up marking because of low space left\n");
speed_up = true;
}
......@@ -1100,8 +1110,9 @@ void IncrementalMarking::SpeedUp() {
if (size_of_old_space_multiplied_by_n_during_marking) {
speed_up = true;
if (FLAG_trace_incremental_marking) {
PrintIsolate(heap()->isolate(),
"Speed up marking because of heap size increase\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Speed up marking because of heap size "
"increase\n");
}
}
......@@ -1114,8 +1125,9 @@ void IncrementalMarking::SpeedUp() {
// 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 (FLAG_trace_incremental_marking) {
PrintIsolate(heap()->isolate(),
"Speed up marking because marker was not keeping up\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Speed up marking because marker was not "
"keeping up\n");
}
speed_up = true;
}
......@@ -1123,16 +1135,18 @@ void IncrementalMarking::SpeedUp() {
if (speed_up) {
if (state_ != MARKING) {
if (FLAG_trace_incremental_marking) {
PrintIsolate(heap()->isolate(),
"Postponing speeding up marking until marking starts\n");
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Postponing speeding up marking until marking "
"starts\n");
}
} else {
marking_speed_ += kMarkingSpeedAccelleration;
marking_speed_ = static_cast<int>(
Min(kMaxMarkingSpeed, static_cast<intptr_t>(marking_speed_ * 1.3)));
if (FLAG_trace_incremental_marking) {
PrintIsolate(heap()->isolate(), "Marking speed increased to %d\n",
marking_speed_);
heap()->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Marking speed increased to %d\n",
marking_speed_);
}
}
}
......@@ -1284,5 +1298,6 @@ void IncrementalMarking::IncrementIdleMarkingDelayCounter() {
void IncrementalMarking::ClearIdleMarkingDelayCounter() {
idle_marking_delay_counter_ = 0;
}
} // namespace internal
} // namespace v8
......@@ -146,14 +146,7 @@ class IncrementalMarking {
ForceMarkingAction marking = DO_NOT_FORCE_MARKING,
ForceCompletionAction completion = FORCE_COMPLETION);
inline void RestartIfNotMarking() {
if (state_ == COMPLETE) {
state_ = MARKING;
if (FLAG_trace_incremental_marking) {
PrintF("[IncrementalMarking] Restarting (new grey objects)\n");
}
}
}
inline void RestartIfNotMarking();
static void RecordWriteFromCode(HeapObject* obj, Object** slot,
Isolate* isolate);
......
......@@ -3136,6 +3136,15 @@ void Isolate::IsolateInForegroundNotification() {
is_isolate_in_background_ = false;
}
void Isolate::PrintWithTimestamp(const char* format, ...) {
base::OS::Print("[%d:%p] %8.0f ms: ", base::OS::GetCurrentProcessId(),
static_cast<void*>(this), time_millis_since_init());
va_list arguments;
va_start(arguments, format);
base::OS::VPrint(format, arguments);
va_end(arguments);
}
bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
StackGuard* stack_guard = isolate_->stack_guard();
#ifdef USE_SIMULATOR
......
......@@ -1165,6 +1165,8 @@ class Isolate {
bool IsIsolateInBackground() { return is_isolate_in_background_; }
void PrintWithTimestamp(const char* format, ...);
protected:
explicit Isolate(bool enable_serializer);
bool IsArrayOrObjectPrototype(Object* object);
......
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