| 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/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 | 592 |
| 593 return NULL; | 593 return NULL; |
| 594 } | 594 } |
| 595 | 595 |
| 596 | 596 |
| 597 void MarkCompactCollector::ComputeEvacuationHeuristics( | 597 void MarkCompactCollector::ComputeEvacuationHeuristics( |
| 598 int area_size, int* target_fragmentation_percent, | 598 int area_size, int* target_fragmentation_percent, |
| 599 int* max_evacuated_bytes) { | 599 int* max_evacuated_bytes) { |
| 600 // For memory reducing mode we directly define both constants. | 600 // For memory reducing mode we directly define both constants. |
| 601 const int kTargetFragmentationPercentForReduceMemory = 20; | 601 const int kTargetFragmentationPercentForReduceMemory = 20; |
| 602 const int kMaxEvacuatedBytesForReduceMemory = 12 * Page::kPageSize; | 602 const int kMaxEvacuatedBytesForReduceMemory = 12 * MB; |
| 603 | 603 |
| 604 // For regular mode (which is latency critical) we define less aggressive | 604 // For regular mode (which is latency critical) we define less aggressive |
| 605 // defaults to start and switch to a trace-based (using compaction speed) | 605 // defaults to start and switch to a trace-based (using compaction speed) |
| 606 // approach as soon as we have enough samples. | 606 // approach as soon as we have enough samples. |
| 607 const int kTargetFragmentationPercent = 70; | 607 const int kTargetFragmentationPercent = 70; |
| 608 const int kMaxEvacuatedBytes = 4 * Page::kPageSize; | 608 const int kMaxEvacuatedBytes = 4 * MB; |
| 609 // Time to take for a single area (=payload of page). Used as soon as there | 609 // Time to take for a single area (=payload of page). Used as soon as there |
| 610 // exist enough compaction speed samples. | 610 // exist enough compaction speed samples. |
| 611 const int kTargetMsPerArea = 1; | 611 const float kTargetMsPerArea = 0.5; |
| 612 | 612 |
| 613 if (heap()->ShouldReduceMemory()) { | 613 if (heap()->ShouldReduceMemory()) { |
| 614 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory; | 614 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory; |
| 615 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory; | 615 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory; |
| 616 } else { | 616 } else { |
| 617 const double estimated_compaction_speed = | 617 const double estimated_compaction_speed = |
| 618 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); | 618 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); |
| 619 if (estimated_compaction_speed != 0) { | 619 if (estimated_compaction_speed != 0) { |
| 620 // Estimate the target fragmentation based on traced compaction speed | 620 // Estimate the target fragmentation based on traced compaction speed |
| 621 // and a goal for a single page. | 621 // and a goal for a single page. |
| (...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3204 | 3204 |
| 3205 int MarkCompactCollector::NumberOfParallelCompactionTasks(int pages, | 3205 int MarkCompactCollector::NumberOfParallelCompactionTasks(int pages, |
| 3206 intptr_t live_bytes) { | 3206 intptr_t live_bytes) { |
| 3207 if (!FLAG_parallel_compaction) return 1; | 3207 if (!FLAG_parallel_compaction) return 1; |
| 3208 // Compute the number of needed tasks based on a target compaction time, the | 3208 // Compute the number of needed tasks based on a target compaction time, the |
| 3209 // profiled compaction speed and marked live memory. | 3209 // profiled compaction speed and marked live memory. |
| 3210 // | 3210 // |
| 3211 // The number of parallel compaction tasks is limited by: | 3211 // The number of parallel compaction tasks is limited by: |
| 3212 // - #evacuation pages | 3212 // - #evacuation pages |
| 3213 // - (#cores - 1) | 3213 // - (#cores - 1) |
| 3214 const double kTargetCompactionTimeInMs = 1; | 3214 const double kTargetCompactionTimeInMs = .5; |
| 3215 const int kNumSweepingTasks = 3; | 3215 const int kNumSweepingTasks = 3; |
| 3216 | 3216 |
| 3217 double compaction_speed = | 3217 double compaction_speed = |
| 3218 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); | 3218 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); |
| 3219 | 3219 |
| 3220 const int available_cores = Max( | 3220 const int available_cores = Max( |
| 3221 1, static_cast<int>( | 3221 1, static_cast<int>( |
| 3222 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) - | 3222 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) - |
| 3223 kNumSweepingTasks - 1); | 3223 kNumSweepingTasks - 1); |
| 3224 int tasks; | 3224 int tasks; |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4021 // The target is always in old space, we don't have to record the slot in | 4021 // The target is always in old space, we don't have to record the slot in |
| 4022 // the old-to-new remembered set. | 4022 // the old-to-new remembered set. |
| 4023 DCHECK(!heap()->InNewSpace(target)); | 4023 DCHECK(!heap()->InNewSpace(target)); |
| 4024 RecordRelocSlot(host, &rinfo, target); | 4024 RecordRelocSlot(host, &rinfo, target); |
| 4025 } | 4025 } |
| 4026 } | 4026 } |
| 4027 } | 4027 } |
| 4028 | 4028 |
| 4029 } // namespace internal | 4029 } // namespace internal |
| 4030 } // namespace v8 | 4030 } // namespace v8 |
| OLD | NEW |