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

Side by Side Diff: src/heap/mark-compact.cc

Issue 2232653003: Reland of "[heap] Switch to 500k pages" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Switch back to using the high water mark. Also: dont sweep immortal immovable pages Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 and optimize for memory mode we directly define both 600 // For memory reducing and optimize for memory mode we directly define both
601 // constants. 601 // constants.
602 const int kTargetFragmentationPercentForReduceMemory = 20; 602 const int kTargetFragmentationPercentForReduceMemory = 20;
603 const int kMaxEvacuatedBytesForReduceMemory = 12 * Page::kPageSize; 603 const int kMaxEvacuatedBytesForReduceMemory = 12 * MB;
604 const int kTargetFragmentationPercentForOptimizeMemory = 20; 604 const int kTargetFragmentationPercentForOptimizeMemory = 20;
605 const int kMaxEvacuatedBytesForOptimizeMemory = 6 * MB; 605 const int kMaxEvacuatedBytesForOptimizeMemory = 6 * MB;
606 606
607 // For regular mode (which is latency critical) we define less aggressive 607 // For regular mode (which is latency critical) we define less aggressive
608 // defaults to start and switch to a trace-based (using compaction speed) 608 // defaults to start and switch to a trace-based (using compaction speed)
609 // approach as soon as we have enough samples. 609 // approach as soon as we have enough samples.
610 const int kTargetFragmentationPercent = 70; 610 const int kTargetFragmentationPercent = 70;
611 const int kMaxEvacuatedBytes = 4 * Page::kPageSize; 611 const int kMaxEvacuatedBytes = 4 * MB;
612 // Time to take for a single area (=payload of page). Used as soon as there 612 // Time to take for a single area (=payload of page). Used as soon as there
613 // exist enough compaction speed samples. 613 // exist enough compaction speed samples.
614 const int kTargetMsPerArea = 1; 614 const float kTargetMsPerArea = 0.5;
615 615
616 if (heap()->ShouldReduceMemory()) { 616 if (heap()->ShouldReduceMemory()) {
617 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory; 617 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory;
618 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory; 618 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory;
619 } else if (heap()->ShouldOptimizeForMemoryUsage()) { 619 } else if (heap()->ShouldOptimizeForMemoryUsage()) {
620 *target_fragmentation_percent = 620 *target_fragmentation_percent =
621 kTargetFragmentationPercentForOptimizeMemory; 621 kTargetFragmentationPercentForOptimizeMemory;
622 *max_evacuated_bytes = kMaxEvacuatedBytesForOptimizeMemory; 622 *max_evacuated_bytes = kMaxEvacuatedBytesForOptimizeMemory;
623 } else { 623 } else {
624 const double estimated_compaction_speed = 624 const double estimated_compaction_speed =
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3211 3211
3212 int MarkCompactCollector::NumberOfParallelCompactionTasks(int pages, 3212 int MarkCompactCollector::NumberOfParallelCompactionTasks(int pages,
3213 intptr_t live_bytes) { 3213 intptr_t live_bytes) {
3214 if (!FLAG_parallel_compaction) return 1; 3214 if (!FLAG_parallel_compaction) return 1;
3215 // Compute the number of needed tasks based on a target compaction time, the 3215 // Compute the number of needed tasks based on a target compaction time, the
3216 // profiled compaction speed and marked live memory. 3216 // profiled compaction speed and marked live memory.
3217 // 3217 //
3218 // The number of parallel compaction tasks is limited by: 3218 // The number of parallel compaction tasks is limited by:
3219 // - #evacuation pages 3219 // - #evacuation pages
3220 // - (#cores - 1) 3220 // - (#cores - 1)
3221 const double kTargetCompactionTimeInMs = 1; 3221 const double kTargetCompactionTimeInMs = .5;
3222 const int kNumSweepingTasks = 3; 3222 const int kNumSweepingTasks = 3;
3223 3223
3224 double compaction_speed = 3224 double compaction_speed =
3225 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); 3225 heap()->tracer()->CompactionSpeedInBytesPerMillisecond();
3226 3226
3227 const int available_cores = Max( 3227 const int available_cores = Max(
3228 1, static_cast<int>( 3228 1, static_cast<int>(
3229 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) - 3229 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) -
3230 kNumSweepingTasks - 1); 3230 kNumSweepingTasks - 1);
3231 int tasks; 3231 int tasks;
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 for (auto it = space->begin(); it != space->end();) { 3911 for (auto it = space->begin(); it != space->end();) {
3912 Page* p = *(it++); 3912 Page* p = *(it++);
3913 DCHECK(p->SweepingDone()); 3913 DCHECK(p->SweepingDone());
3914 3914
3915 if (p->IsEvacuationCandidate()) { 3915 if (p->IsEvacuationCandidate()) {
3916 // Will be processed in EvacuateNewSpaceAndCandidates. 3916 // Will be processed in EvacuateNewSpaceAndCandidates.
3917 DCHECK(evacuation_candidates_.length() > 0); 3917 DCHECK(evacuation_candidates_.length() > 0);
3918 continue; 3918 continue;
3919 } 3919 }
3920 3920
3921 if (p->IsFlagSet(Page::NEVER_SWEEP)) {
3922 p->ClearLiveness();
3923 continue;
3924 }
3925
3921 if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) { 3926 if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) {
3922 // We need to sweep the page to get it into an iterable state again. Note 3927 // We need to sweep the page to get it into an iterable state again. Note
3923 // that this adds unusable memory into the free list that is later on 3928 // that this adds unusable memory into the free list that is later on
3924 // (in the free list) dropped again. Since we only use the flag for 3929 // (in the free list) dropped again. Since we only use the flag for
3925 // testing this is fine. 3930 // testing this is fine.
3926 p->concurrent_sweeping_state().SetValue(Page::kSweepingInProgress); 3931 p->concurrent_sweeping_state().SetValue(Page::kSweepingInProgress);
3927 Sweeper::RawSweep(p, Sweeper::IGNORE_FREE_LIST, 3932 Sweeper::RawSweep(p, Sweeper::IGNORE_FREE_LIST,
3928 Heap::ShouldZapGarbage() ? Sweeper::ZAP_FREE_SPACE 3933 Heap::ShouldZapGarbage() ? Sweeper::ZAP_FREE_SPACE
3929 : Sweeper::IGNORE_FREE_SPACE); 3934 : Sweeper::IGNORE_FREE_SPACE);
3930 continue; 3935 continue;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 // The target is always in old space, we don't have to record the slot in 4033 // The target is always in old space, we don't have to record the slot in
4029 // the old-to-new remembered set. 4034 // the old-to-new remembered set.
4030 DCHECK(!heap()->InNewSpace(target)); 4035 DCHECK(!heap()->InNewSpace(target));
4031 RecordRelocSlot(host, &rinfo, target); 4036 RecordRelocSlot(host, &rinfo, target);
4032 } 4037 }
4033 } 4038 }
4034 } 4039 }
4035 4040
4036 } // namespace internal 4041 } // namespace internal
4037 } // namespace v8 4042 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces.h » ('j') | src/heap/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698