Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Unified Diff: src/heap/heap.cc

Issue 750813003: Use deadline in IdleNotification. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | test/unittests/heap/gc-idle-time-handler-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 97c7d6dac6434437fa50fa647294c34addbc379f..6811eca20a5f5943f681f10413cb0ef36fe7973e 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -4392,10 +4392,13 @@ 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>(idle_time_in_ms));
+}
+
+
+bool Heap::IdleNotification(double deadline) {
HistogramTimerScope idle_notification_scope(
isolate_->counters()->gc_idle_notification());
@@ -4422,11 +4425,14 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
static_cast<size_t>(
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
+ double idle_time =
+ deadline - V8::GetCurrentPlatform()->MonotonicallyIncreasingTime();
rmcilroy 2014/11/25 10:35:41 Both deadline and MonotonicallyIncreasingTime() re
Hannes Payer (out of office) 2014/11/25 12:28:59 I am using now seconds granularity on the api leve
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 +4445,12 @@ 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 - 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 +4476,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 - 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) {
« no previous file with comments | « src/heap/heap.h ('k') | test/unittests/heap/gc-idle-time-handler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698