Chromium Code Reviews| Index: src/heap/heap.cc |
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
| index 97c7d6dac6434437fa50fa647294c34addbc379f..dd11c0f58cf56eed83b15c0dd8f34ec4312b6199 100644 |
| --- a/src/heap/heap.cc |
| +++ b/src/heap/heap.cc |
| @@ -4392,10 +4392,14 @@ bool Heap::WorthActivatingIncrementalMarking() { |
| bool Heap::IdleNotification(int idle_time_in_ms) { |
| - base::ElapsedTimer timer; |
| - timer.Start(); |
| - isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
| - idle_time_in_ms); |
| + return IdleNotification( |
| + (V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
| + static_cast<double>(base::Time::kMicrosecondsPerSecond)) + |
| + 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.
|
| +} |
| + |
| + |
| +bool Heap::IdleNotification(double deadline_in_ms) { |
| HistogramTimerScope idle_notification_scope( |
| isolate_->counters()->gc_idle_notification()); |
| @@ -4422,11 +4426,14 @@ bool Heap::IdleNotification(int idle_time_in_ms) { |
| static_cast<size_t>( |
| tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); |
| + double idle_time = |
| + 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.
|
| GCIdleTimeAction action = |
| - gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); |
| + gc_idle_time_handler_.Compute(idle_time, heap_state); |
| + isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
| + static_cast<int>(idle_time)); |
| bool result = false; |
| - int actual_time_in_ms = 0; |
| switch (action.type) { |
| case DONE: |
| result = true; |
| @@ -4439,11 +4446,13 @@ bool Heap::IdleNotification(int idle_time_in_ms) { |
| IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| IncrementalMarking::FORCE_MARKING, |
| IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
| - actual_time_in_ms = static_cast<int>(timer.Elapsed().InMilliseconds()); |
| - int remaining_idle_time_in_ms = idle_time_in_ms - actual_time_in_ms; |
| - if (remaining_idle_time_in_ms > 0) { |
| + double remaining_idle_time_in_ms = |
| + deadline_in_ms - |
| + V8::GetCurrentPlatform()->MonotonicallyIncreasingTime(); |
| + if (remaining_idle_time_in_ms > 0.0) { |
| TryFinalizeIdleIncrementalMarking( |
| - remaining_idle_time_in_ms, heap_state.size_of_objects, |
| + static_cast<size_t>(remaining_idle_time_in_ms), |
| + heap_state.size_of_objects, |
| heap_state.mark_compact_speed_in_bytes_per_ms); |
| } |
| break; |
| @@ -4469,20 +4478,24 @@ bool Heap::IdleNotification(int idle_time_in_ms) { |
| break; |
| } |
| - actual_time_in_ms = static_cast<int>(timer.Elapsed().InMilliseconds()); |
| - if (actual_time_in_ms <= idle_time_in_ms) { |
| + |
| + double deadline_difference = |
| + deadline_in_ms - V8::GetCurrentPlatform()->MonotonicallyIncreasingTime(); |
| + if (deadline_difference >= 0) { |
| if (action.type != DONE && action.type != DO_NOTHING) { |
| isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( |
| - idle_time_in_ms - actual_time_in_ms); |
| + static_cast<int>(deadline_difference)); |
| } |
| } else { |
| isolate()->counters()->gc_idle_time_limit_overshot()->AddSample( |
| - actual_time_in_ms - idle_time_in_ms); |
| + static_cast<int>(-deadline_difference)); |
| } |
| if (FLAG_trace_idle_notification) { |
| - PrintF("Idle notification: requested idle time %d ms, actual time %d ms [", |
| - idle_time_in_ms, actual_time_in_ms); |
| + PrintF( |
| + "Idle notification: requested idle time %.2f ms, deadline difference " |
| + "%.2f ms [", |
| + idle_time, deadline_difference); |
| action.Print(); |
| PrintF("]"); |
| if (FLAG_trace_idle_notification_verbose) { |