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 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 | 3207 |
3208 int MarkCompactCollector::NumberOfParallelCompactionTasks(int pages, | 3208 int MarkCompactCollector::NumberOfParallelCompactionTasks(int pages, |
3209 intptr_t live_bytes) { | 3209 intptr_t live_bytes) { |
3210 if (!FLAG_parallel_compaction) return 1; | 3210 if (!FLAG_parallel_compaction) return 1; |
3211 // Compute the number of needed tasks based on a target compaction time, the | 3211 // Compute the number of needed tasks based on a target compaction time, the |
3212 // profiled compaction speed and marked live memory. | 3212 // profiled compaction speed and marked live memory. |
3213 // | 3213 // |
3214 // The number of parallel compaction tasks is limited by: | 3214 // The number of parallel compaction tasks is limited by: |
3215 // - #evacuation pages | 3215 // - #evacuation pages |
3216 // - (#cores - 1) | 3216 // - (#cores - 1) |
3217 const double kTargetCompactionTimeInMs = 1; | 3217 const double kTargetCompactionTimeInMs = .5; |
3218 const int kNumSweepingTasks = 3; | 3218 const int kNumSweepingTasks = 3; |
3219 | 3219 |
3220 double compaction_speed = | 3220 double compaction_speed = |
3221 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); | 3221 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); |
3222 | 3222 |
3223 const int available_cores = Max( | 3223 const int available_cores = Max( |
3224 1, static_cast<int>( | 3224 1, static_cast<int>( |
3225 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) - | 3225 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) - |
3226 kNumSweepingTasks - 1); | 3226 kNumSweepingTasks - 1); |
3227 int tasks; | 3227 int tasks; |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4041 // The target is always in old space, we don't have to record the slot in | 4041 // The target is always in old space, we don't have to record the slot in |
4042 // the old-to-new remembered set. | 4042 // the old-to-new remembered set. |
4043 DCHECK(!heap()->InNewSpace(target)); | 4043 DCHECK(!heap()->InNewSpace(target)); |
4044 RecordRelocSlot(host, &rinfo, target); | 4044 RecordRelocSlot(host, &rinfo, target); |
4045 } | 4045 } |
4046 } | 4046 } |
4047 } | 4047 } |
4048 | 4048 |
4049 } // namespace internal | 4049 } // namespace internal |
4050 } // namespace v8 | 4050 } // namespace v8 |
OLD | NEW |