Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 4374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4385 } | 4385 } |
| 4386 | 4386 |
| 4387 | 4387 |
| 4388 bool Heap::WorthActivatingIncrementalMarking() { | 4388 bool Heap::WorthActivatingIncrementalMarking() { |
| 4389 return incremental_marking()->IsStopped() && | 4389 return incremental_marking()->IsStopped() && |
| 4390 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); | 4390 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); |
| 4391 } | 4391 } |
| 4392 | 4392 |
| 4393 | 4393 |
| 4394 bool Heap::IdleNotification(int idle_time_in_ms) { | 4394 bool Heap::IdleNotification(int idle_time_in_ms) { |
| 4395 base::ElapsedTimer timer; | 4395 return IdleNotification( |
| 4396 timer.Start(); | 4396 (V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
| 4397 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | 4397 static_cast<double>(base::Time::kMicrosecondsPerSecond)) + |
| 4398 idle_time_in_ms); | 4398 static_cast<double>(idle_time_in_ms)); |
|
rmcilroy
2014/11/25 14:28:06
indentation.
Hannes Payer (out of office)
2014/11/25 16:01:36
gc format is formatting it like that.
| |
| 4399 } | |
| 4400 | |
| 4401 | |
| 4402 bool Heap::IdleNotification(double deadline_in_ms) { | |
| 4399 HistogramTimerScope idle_notification_scope( | 4403 HistogramTimerScope idle_notification_scope( |
| 4400 isolate_->counters()->gc_idle_notification()); | 4404 isolate_->counters()->gc_idle_notification()); |
| 4401 | 4405 |
| 4402 GCIdleTimeHandler::HeapState heap_state; | 4406 GCIdleTimeHandler::HeapState heap_state; |
| 4403 heap_state.contexts_disposed = contexts_disposed_; | 4407 heap_state.contexts_disposed = contexts_disposed_; |
| 4404 heap_state.contexts_disposal_rate = | 4408 heap_state.contexts_disposal_rate = |
| 4405 tracer()->ContextDisposalRateInMilliseconds(); | 4409 tracer()->ContextDisposalRateInMilliseconds(); |
| 4406 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4410 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); |
| 4407 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); | 4411 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); |
| 4408 // TODO(ulan): Start incremental marking only for large heaps. | 4412 // TODO(ulan): Start incremental marking only for large heaps. |
| 4409 heap_state.can_start_incremental_marking = | 4413 heap_state.can_start_incremental_marking = |
| 4410 incremental_marking()->ShouldActivate() && FLAG_incremental_marking; | 4414 incremental_marking()->ShouldActivate() && FLAG_incremental_marking; |
| 4411 heap_state.sweeping_in_progress = | 4415 heap_state.sweeping_in_progress = |
| 4412 mark_compact_collector()->sweeping_in_progress(); | 4416 mark_compact_collector()->sweeping_in_progress(); |
| 4413 heap_state.mark_compact_speed_in_bytes_per_ms = | 4417 heap_state.mark_compact_speed_in_bytes_per_ms = |
| 4414 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); | 4418 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); |
| 4415 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( | 4419 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( |
| 4416 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); | 4420 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); |
| 4417 heap_state.scavenge_speed_in_bytes_per_ms = | 4421 heap_state.scavenge_speed_in_bytes_per_ms = |
| 4418 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); | 4422 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); |
| 4419 heap_state.used_new_space_size = new_space_.Size(); | 4423 heap_state.used_new_space_size = new_space_.Size(); |
| 4420 heap_state.new_space_capacity = new_space_.Capacity(); | 4424 heap_state.new_space_capacity = new_space_.Capacity(); |
| 4421 heap_state.new_space_allocation_throughput_in_bytes_per_ms = | 4425 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
| 4422 static_cast<size_t>( | 4426 static_cast<size_t>( |
| 4423 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); | 4427 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); |
| 4424 | 4428 |
| 4429 double idle_time = | |
| 4430 deadline_in_ms - V8::GetCurrentPlatform()->MonotonicallyIncreasingTime(); | |
|
rmcilroy
2014/11/25 14:28:06
still subtracting seconds from ms here.
Hannes Payer (out of office)
2014/11/25 16:01:36
Done.
| |
| 4425 GCIdleTimeAction action = | 4431 GCIdleTimeAction action = |
| 4426 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); | 4432 gc_idle_time_handler_.Compute(idle_time, heap_state); |
| 4433 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | |
| 4434 static_cast<int>(idle_time)); | |
| 4427 | 4435 |
| 4428 bool result = false; | 4436 bool result = false; |
| 4429 int actual_time_in_ms = 0; | |
| 4430 switch (action.type) { | 4437 switch (action.type) { |
| 4431 case DONE: | 4438 case DONE: |
| 4432 result = true; | 4439 result = true; |
| 4433 break; | 4440 break; |
| 4434 case DO_INCREMENTAL_MARKING: { | 4441 case DO_INCREMENTAL_MARKING: { |
| 4435 if (incremental_marking()->IsStopped()) { | 4442 if (incremental_marking()->IsStopped()) { |
| 4436 incremental_marking()->Start(); | 4443 incremental_marking()->Start(); |
| 4437 } | 4444 } |
| 4438 incremental_marking()->Step(action.parameter, | 4445 incremental_marking()->Step(action.parameter, |
| 4439 IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 4446 IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 4440 IncrementalMarking::FORCE_MARKING, | 4447 IncrementalMarking::FORCE_MARKING, |
| 4441 IncrementalMarking::DO_NOT_FORCE_COMPLETION); | 4448 IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
| 4442 actual_time_in_ms = static_cast<int>(timer.Elapsed().InMilliseconds()); | 4449 double remaining_idle_time_in_ms = |
| 4443 int remaining_idle_time_in_ms = idle_time_in_ms - actual_time_in_ms; | 4450 deadline_in_ms - |
| 4444 if (remaining_idle_time_in_ms > 0) { | 4451 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime(); |
| 4452 if (remaining_idle_time_in_ms > 0.0) { | |
| 4445 TryFinalizeIdleIncrementalMarking( | 4453 TryFinalizeIdleIncrementalMarking( |
| 4446 remaining_idle_time_in_ms, heap_state.size_of_objects, | 4454 static_cast<size_t>(remaining_idle_time_in_ms), |
| 4455 heap_state.size_of_objects, | |
| 4447 heap_state.mark_compact_speed_in_bytes_per_ms); | 4456 heap_state.mark_compact_speed_in_bytes_per_ms); |
| 4448 } | 4457 } |
| 4449 break; | 4458 break; |
| 4450 } | 4459 } |
| 4451 case DO_FULL_GC: { | 4460 case DO_FULL_GC: { |
| 4452 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4461 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4453 if (contexts_disposed_) { | 4462 if (contexts_disposed_) { |
| 4454 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); | 4463 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); |
| 4455 gc_idle_time_handler_.NotifyIdleMarkCompact(); | 4464 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
| 4456 gc_count_at_last_idle_gc_ = gc_count_; | 4465 gc_count_at_last_idle_gc_ = gc_count_; |
| 4457 } else { | 4466 } else { |
| 4458 IdleMarkCompact("idle notification: finalize idle round"); | 4467 IdleMarkCompact("idle notification: finalize idle round"); |
| 4459 } | 4468 } |
| 4460 break; | 4469 break; |
| 4461 } | 4470 } |
| 4462 case DO_SCAVENGE: | 4471 case DO_SCAVENGE: |
| 4463 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); | 4472 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); |
| 4464 break; | 4473 break; |
| 4465 case DO_FINALIZE_SWEEPING: | 4474 case DO_FINALIZE_SWEEPING: |
| 4466 mark_compact_collector()->EnsureSweepingCompleted(); | 4475 mark_compact_collector()->EnsureSweepingCompleted(); |
| 4467 break; | 4476 break; |
| 4468 case DO_NOTHING: | 4477 case DO_NOTHING: |
| 4469 break; | 4478 break; |
| 4470 } | 4479 } |
| 4471 | 4480 |
| 4472 actual_time_in_ms = static_cast<int>(timer.Elapsed().InMilliseconds()); | 4481 |
| 4473 if (actual_time_in_ms <= idle_time_in_ms) { | 4482 double deadline_difference = |
| 4483 deadline_in_ms - V8::GetCurrentPlatform()->MonotonicallyIncreasingTime(); | |
| 4484 if (deadline_difference >= 0) { | |
| 4474 if (action.type != DONE && action.type != DO_NOTHING) { | 4485 if (action.type != DONE && action.type != DO_NOTHING) { |
| 4475 isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( | 4486 isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( |
| 4476 idle_time_in_ms - actual_time_in_ms); | 4487 static_cast<int>(deadline_difference)); |
| 4477 } | 4488 } |
| 4478 } else { | 4489 } else { |
| 4479 isolate()->counters()->gc_idle_time_limit_overshot()->AddSample( | 4490 isolate()->counters()->gc_idle_time_limit_overshot()->AddSample( |
| 4480 actual_time_in_ms - idle_time_in_ms); | 4491 static_cast<int>(-deadline_difference)); |
| 4481 } | 4492 } |
| 4482 | 4493 |
| 4483 if (FLAG_trace_idle_notification) { | 4494 if (FLAG_trace_idle_notification) { |
| 4484 PrintF("Idle notification: requested idle time %d ms, actual time %d ms [", | 4495 PrintF( |
| 4485 idle_time_in_ms, actual_time_in_ms); | 4496 "Idle notification: requested idle time %.2f ms, deadline difference " |
| 4497 "%.2f ms [", | |
| 4498 idle_time, deadline_difference); | |
| 4486 action.Print(); | 4499 action.Print(); |
| 4487 PrintF("]"); | 4500 PrintF("]"); |
| 4488 if (FLAG_trace_idle_notification_verbose) { | 4501 if (FLAG_trace_idle_notification_verbose) { |
| 4489 PrintF("["); | 4502 PrintF("["); |
| 4490 heap_state.Print(); | 4503 heap_state.Print(); |
| 4491 PrintF("]"); | 4504 PrintF("]"); |
| 4492 } | 4505 } |
| 4493 PrintF("\n"); | 4506 PrintF("\n"); |
| 4494 } | 4507 } |
| 4495 | 4508 |
| (...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6311 static_cast<int>(object_sizes_last_time_[index])); | 6324 static_cast<int>(object_sizes_last_time_[index])); |
| 6312 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6325 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6313 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6326 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6314 | 6327 |
| 6315 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6328 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6316 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6329 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6317 ClearObjectStats(); | 6330 ClearObjectStats(); |
| 6318 } | 6331 } |
| 6319 } | 6332 } |
| 6320 } // namespace v8::internal | 6333 } // namespace v8::internal |
| OLD | NEW |