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/once.h" | 9 #include "src/base/once.h" |
| 10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| (...skipping 4264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4275 mark_sweeps_since_idle_round_started_++; | 4275 mark_sweeps_since_idle_round_started_++; |
| 4276 gc_count_at_last_idle_gc_ = gc_count_; | 4276 gc_count_at_last_idle_gc_ = gc_count_; |
| 4277 if (uncommit) { | 4277 if (uncommit) { |
| 4278 new_space_.Shrink(); | 4278 new_space_.Shrink(); |
| 4279 UncommitFromSpace(); | 4279 UncommitFromSpace(); |
| 4280 } | 4280 } |
| 4281 } | 4281 } |
| 4282 } | 4282 } |
| 4283 | 4283 |
| 4284 | 4284 |
| 4285 bool Heap::IdleNotification(int hint) { | 4285 bool Heap::IdleNotification(int idle_time_in_ms) { |
| 4286 // If incremental marking is off, we do not perform idle notification. | 4286 // If incremental marking is off, we do not perform idle notification. |
| 4287 if (!FLAG_incremental_marking) return true; | 4287 if (!FLAG_incremental_marking) return true; |
| 4288 | 4288 |
| 4289 // Hints greater than this value indicate that | |
| 4290 // the embedder is requesting a lot of GC work. | |
| 4291 const int kMaxHint = 1000; | |
| 4292 const int kMinHintForIncrementalMarking = 10; | |
| 4293 // Minimal hint that allows to do full GC. | 4289 // Minimal hint that allows to do full GC. |
| 4294 const int kMinHintForFullGC = 100; | 4290 const int kMinHintForFullGC = 100; |
| 4295 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; | 4291 // We have to make sure that we finish the IdleNotification before |
| 4296 // The size factor is in range [5..250]. The numbers here are chosen from | 4292 // idle_time_in_ms. Hence, we conservatively prune our workload estimate. |
| 4297 // experiments. If you changes them, make sure to test with | 4293 const int kConservativeTimeRatio = 90; |
| 4298 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* | 4294 intptr_t step_size = |
| 4299 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; | 4295 ((tracer_.IncrementalMarkingSpeedInBytesPerMillisecond() / 100) * |
|
jochen (gone - plz use gerrit)
2014/08/12 08:35:24
why not just * 0.9 - that might be safer wrt integ
Hannes Payer (out of office)
2014/08/12 09:48:56
I usually prefer integers, but I changed it to dou
| |
| 4300 | 4296 kConservativeTimeRatio) * |
| 4301 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample(hint); | 4297 idle_time_in_ms; |
| 4298 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | |
| 4299 idle_time_in_ms); | |
| 4302 HistogramTimerScope idle_notification_scope( | 4300 HistogramTimerScope idle_notification_scope( |
| 4303 isolate_->counters()->gc_idle_notification()); | 4301 isolate_->counters()->gc_idle_notification()); |
| 4304 | 4302 |
| 4305 if (contexts_disposed_ > 0) { | 4303 if (contexts_disposed_ > 0) { |
| 4306 contexts_disposed_ = 0; | 4304 contexts_disposed_ = 0; |
| 4307 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); | 4305 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); |
| 4308 if (hint >= mark_sweep_time && !FLAG_expose_gc && | 4306 if (idle_time_in_ms >= mark_sweep_time && !FLAG_expose_gc && |
| 4309 incremental_marking()->IsStopped()) { | 4307 incremental_marking()->IsStopped()) { |
| 4310 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4308 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4311 CollectAllGarbage(kReduceMemoryFootprintMask, | 4309 CollectAllGarbage(kReduceMemoryFootprintMask, |
| 4312 "idle notification: contexts disposed"); | 4310 "idle notification: contexts disposed"); |
| 4313 } else { | 4311 } else { |
| 4314 AdvanceIdleIncrementalMarking(step_size); | 4312 AdvanceIdleIncrementalMarking(step_size); |
| 4315 } | 4313 } |
| 4316 | 4314 |
| 4317 // After context disposal there is likely a lot of garbage remaining, reset | 4315 // After context disposal there is likely a lot of garbage remaining, reset |
| 4318 // the idle notification counters in order to trigger more incremental GCs | 4316 // the idle notification counters in order to trigger more incremental GCs |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 4339 | 4337 |
| 4340 int remaining_mark_sweeps = | 4338 int remaining_mark_sweeps = |
| 4341 kMaxMarkSweepsInIdleRound - mark_sweeps_since_idle_round_started_; | 4339 kMaxMarkSweepsInIdleRound - mark_sweeps_since_idle_round_started_; |
| 4342 | 4340 |
| 4343 if (incremental_marking()->IsStopped()) { | 4341 if (incremental_marking()->IsStopped()) { |
| 4344 // If there are no more than two GCs left in this idle round and we are | 4342 // If there are no more than two GCs left in this idle round and we are |
| 4345 // allowed to do a full GC, then make those GCs full in order to compact | 4343 // allowed to do a full GC, then make those GCs full in order to compact |
| 4346 // the code space. | 4344 // the code space. |
| 4347 // TODO(ulan): Once we enable code compaction for incremental marking, | 4345 // TODO(ulan): Once we enable code compaction for incremental marking, |
| 4348 // we can get rid of this special case and always start incremental marking. | 4346 // we can get rid of this special case and always start incremental marking. |
| 4349 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) { | 4347 if (remaining_mark_sweeps <= 2 && idle_time_in_ms >= kMinHintForFullGC) { |
| 4350 CollectAllGarbage(kReduceMemoryFootprintMask, | 4348 CollectAllGarbage(kReduceMemoryFootprintMask, |
| 4351 "idle notification: finalize idle round"); | 4349 "idle notification: finalize idle round"); |
| 4352 mark_sweeps_since_idle_round_started_++; | 4350 mark_sweeps_since_idle_round_started_++; |
| 4353 } else if (hint > kMinHintForIncrementalMarking) { | 4351 } else { |
| 4354 incremental_marking()->Start(); | 4352 incremental_marking()->Start(); |
| 4355 } | 4353 } |
| 4356 } | 4354 } |
| 4357 if (!incremental_marking()->IsStopped() && | 4355 if (!incremental_marking()->IsStopped()) { |
| 4358 hint > kMinHintForIncrementalMarking) { | |
| 4359 AdvanceIdleIncrementalMarking(step_size); | 4356 AdvanceIdleIncrementalMarking(step_size); |
| 4360 } | 4357 } |
| 4361 | 4358 |
| 4362 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { | 4359 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { |
| 4363 FinishIdleRound(); | 4360 FinishIdleRound(); |
| 4364 return true; | 4361 return true; |
| 4365 } | 4362 } |
| 4366 | 4363 |
| 4367 // If the IdleNotifcation is called with a large hint we will wait for | 4364 // If the IdleNotifcation is called with a large hint we will wait for |
| 4368 // the sweepter threads here. | 4365 // the sweepter threads here. |
| 4369 if (hint >= kMinHintForFullGC && | 4366 if (idle_time_in_ms >= kMinHintForFullGC && |
| 4370 mark_compact_collector()->sweeping_in_progress()) { | 4367 mark_compact_collector()->sweeping_in_progress()) { |
| 4371 mark_compact_collector()->EnsureSweepingCompleted(); | 4368 mark_compact_collector()->EnsureSweepingCompleted(); |
| 4372 } | 4369 } |
| 4373 | 4370 |
| 4374 return false; | 4371 return false; |
| 4375 } | 4372 } |
| 4376 | 4373 |
| 4377 | 4374 |
| 4378 #ifdef DEBUG | 4375 #ifdef DEBUG |
| 4379 | 4376 |
| (...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6143 static_cast<int>(object_sizes_last_time_[index])); | 6140 static_cast<int>(object_sizes_last_time_[index])); |
| 6144 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6141 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6145 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6142 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6146 | 6143 |
| 6147 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6144 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6148 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6145 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6149 ClearObjectStats(); | 6146 ClearObjectStats(); |
| 6150 } | 6147 } |
| 6151 } | 6148 } |
| 6152 } // namespace v8::internal | 6149 } // namespace v8::internal |
| OLD | NEW |