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

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

Issue 1841043002: Represent speed in GCTracer functions as double instead of int. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/scavenge-job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 const int kTargetFragmentationPercent = 70; 637 const int kTargetFragmentationPercent = 70;
638 const int kMaxEvacuatedBytes = 4 * Page::kPageSize; 638 const int kMaxEvacuatedBytes = 4 * Page::kPageSize;
639 // Time to take for a single area (=payload of page). Used as soon as there 639 // Time to take for a single area (=payload of page). Used as soon as there
640 // exist enough compaction speed samples. 640 // exist enough compaction speed samples.
641 const int kTargetMsPerArea = 1; 641 const int kTargetMsPerArea = 1;
642 642
643 if (heap()->ShouldReduceMemory()) { 643 if (heap()->ShouldReduceMemory()) {
644 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory; 644 *target_fragmentation_percent = kTargetFragmentationPercentForReduceMemory;
645 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory; 645 *max_evacuated_bytes = kMaxEvacuatedBytesForReduceMemory;
646 } else { 646 } else {
647 const intptr_t estimated_compaction_speed = 647 const double estimated_compaction_speed =
648 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); 648 heap()->tracer()->CompactionSpeedInBytesPerMillisecond();
649 if (estimated_compaction_speed != 0) { 649 if (estimated_compaction_speed != 0) {
650 // Estimate the target fragmentation based on traced compaction speed 650 // Estimate the target fragmentation based on traced compaction speed
651 // and a goal for a single page. 651 // and a goal for a single page.
652 const intptr_t estimated_ms_per_area = 652 const double estimated_ms_per_area =
653 1 + static_cast<intptr_t>(area_size) / estimated_compaction_speed; 653 1 + area_size / estimated_compaction_speed;
654 *target_fragmentation_percent = 654 *target_fragmentation_percent = static_cast<int>(
655 100 - 100 * kTargetMsPerArea / estimated_ms_per_area; 655 100 - 100 * kTargetMsPerArea / estimated_ms_per_area);
656 if (*target_fragmentation_percent < 656 if (*target_fragmentation_percent <
657 kTargetFragmentationPercentForReduceMemory) { 657 kTargetFragmentationPercentForReduceMemory) {
658 *target_fragmentation_percent = 658 *target_fragmentation_percent =
659 kTargetFragmentationPercentForReduceMemory; 659 kTargetFragmentationPercentForReduceMemory;
660 } 660 }
661 } else { 661 } else {
662 *target_fragmentation_percent = kTargetFragmentationPercent; 662 *target_fragmentation_percent = kTargetFragmentationPercent;
663 } 663 }
664 *max_evacuated_bytes = kMaxEvacuatedBytes; 664 *max_evacuated_bytes = kMaxEvacuatedBytes;
665 } 665 }
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 if (!FLAG_parallel_compaction) return 1; 3037 if (!FLAG_parallel_compaction) return 1;
3038 // Compute the number of needed tasks based on a target compaction time, the 3038 // Compute the number of needed tasks based on a target compaction time, the
3039 // profiled compaction speed and marked live memory. 3039 // profiled compaction speed and marked live memory.
3040 // 3040 //
3041 // The number of parallel compaction tasks is limited by: 3041 // The number of parallel compaction tasks is limited by:
3042 // - #evacuation pages 3042 // - #evacuation pages
3043 // - (#cores - 1) 3043 // - (#cores - 1)
3044 const double kTargetCompactionTimeInMs = 1; 3044 const double kTargetCompactionTimeInMs = 1;
3045 const int kNumSweepingTasks = 3; 3045 const int kNumSweepingTasks = 3;
3046 3046
3047 intptr_t compaction_speed = 3047 double compaction_speed =
3048 heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); 3048 heap()->tracer()->CompactionSpeedInBytesPerMillisecond();
3049 3049
3050 const int available_cores = Max( 3050 const int available_cores = Max(
3051 1, static_cast<int>( 3051 1, static_cast<int>(
3052 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) - 3052 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()) -
3053 kNumSweepingTasks - 1); 3053 kNumSweepingTasks - 1);
3054 int tasks; 3054 int tasks;
3055 if (compaction_speed > 0) { 3055 if (compaction_speed > 0) {
3056 tasks = 1 + static_cast<int>(static_cast<double>(live_bytes) / 3056 tasks = 1 + static_cast<int>(live_bytes / compaction_speed /
3057 compaction_speed / kTargetCompactionTimeInMs); 3057 kTargetCompactionTimeInMs);
3058 } else { 3058 } else {
3059 tasks = pages; 3059 tasks = pages;
3060 } 3060 }
3061 const int tasks_capped_pages = Min(pages, tasks); 3061 const int tasks_capped_pages = Min(pages, tasks);
3062 return Min(available_cores, tasks_capped_pages); 3062 return Min(available_cores, tasks_capped_pages);
3063 } 3063 }
3064 3064
3065 class EvacuationJobTraits { 3065 class EvacuationJobTraits {
3066 public: 3066 public:
3067 typedef int* PerPageData; // Pointer to number of aborted pages. 3067 typedef int* PerPageData; // Pointer to number of aborted pages.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 live_bytes += page->LiveBytes(); 3114 live_bytes += page->LiveBytes();
3115 job.AddPage(page, &abandoned_pages); 3115 job.AddPage(page, &abandoned_pages);
3116 } 3116 }
3117 for (NewSpacePage* page : newspace_evacuation_candidates_) { 3117 for (NewSpacePage* page : newspace_evacuation_candidates_) {
3118 live_bytes += page->LiveBytes(); 3118 live_bytes += page->LiveBytes();
3119 job.AddPage(page, &abandoned_pages); 3119 job.AddPage(page, &abandoned_pages);
3120 } 3120 }
3121 DCHECK_GE(job.NumberOfPages(), 1); 3121 DCHECK_GE(job.NumberOfPages(), 1);
3122 3122
3123 // Used for trace summary. 3123 // Used for trace summary.
3124 intptr_t compaction_speed = 0; 3124 double compaction_speed = 0;
3125 if (FLAG_trace_evacuation) { 3125 if (FLAG_trace_evacuation) {
3126 compaction_speed = heap()->tracer()->CompactionSpeedInBytesPerMillisecond(); 3126 compaction_speed = heap()->tracer()->CompactionSpeedInBytesPerMillisecond();
3127 } 3127 }
3128 3128
3129 const int wanted_num_tasks = 3129 const int wanted_num_tasks =
3130 NumberOfParallelCompactionTasks(job.NumberOfPages(), live_bytes); 3130 NumberOfParallelCompactionTasks(job.NumberOfPages(), live_bytes);
3131 Evacuator** evacuators = new Evacuator*[wanted_num_tasks]; 3131 Evacuator** evacuators = new Evacuator*[wanted_num_tasks];
3132 for (int i = 0; i < wanted_num_tasks; i++) { 3132 for (int i = 0; i < wanted_num_tasks; i++) {
3133 evacuators[i] = new Evacuator(this); 3133 evacuators[i] = new Evacuator(this);
3134 } 3134 }
3135 job.Run(wanted_num_tasks, [evacuators](int i) { return evacuators[i]; }); 3135 job.Run(wanted_num_tasks, [evacuators](int i) { return evacuators[i]; });
3136 for (int i = 0; i < wanted_num_tasks; i++) { 3136 for (int i = 0; i < wanted_num_tasks; i++) {
3137 evacuators[i]->Finalize(); 3137 evacuators[i]->Finalize();
3138 delete evacuators[i]; 3138 delete evacuators[i];
3139 } 3139 }
3140 delete[] evacuators; 3140 delete[] evacuators;
3141 3141
3142 if (FLAG_trace_evacuation) { 3142 if (FLAG_trace_evacuation) {
3143 PrintIsolate( 3143 PrintIsolate(
3144 isolate(), 3144 isolate(),
3145 "%8.0f ms: evacuation-summary: parallel=%s pages=%d aborted=%d " 3145 "%8.0f ms: evacuation-summary: parallel=%s pages=%d aborted=%d "
3146 "wanted_tasks=%d tasks=%d cores=%d live_bytes=%" V8_PTR_PREFIX 3146 "wanted_tasks=%d tasks=%d cores=%d live_bytes=%" V8_PTR_PREFIX
3147 "d compaction_speed=%" V8_PTR_PREFIX "d\n", 3147 "d compaction_speed=%.f\n",
3148 isolate()->time_millis_since_init(), 3148 isolate()->time_millis_since_init(),
3149 FLAG_parallel_compaction ? "yes" : "no", job.NumberOfPages(), 3149 FLAG_parallel_compaction ? "yes" : "no", job.NumberOfPages(),
3150 abandoned_pages, wanted_num_tasks, job.NumberOfTasks(), 3150 abandoned_pages, wanted_num_tasks, job.NumberOfTasks(),
3151 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads(), 3151 V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads(),
3152 live_bytes, compaction_speed); 3152 live_bytes, compaction_speed);
3153 } 3153 }
3154 } 3154 }
3155 3155
3156 class EvacuationWeakObjectRetainer : public WeakObjectRetainer { 3156 class EvacuationWeakObjectRetainer : public WeakObjectRetainer {
3157 public: 3157 public:
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 MarkBit mark_bit = Marking::MarkBitFrom(host); 3809 MarkBit mark_bit = Marking::MarkBitFrom(host);
3810 if (Marking::IsBlack(mark_bit)) { 3810 if (Marking::IsBlack(mark_bit)) {
3811 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3811 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3812 RecordRelocSlot(host, &rinfo, target); 3812 RecordRelocSlot(host, &rinfo, target);
3813 } 3813 }
3814 } 3814 }
3815 } 3815 }
3816 3816
3817 } // namespace internal 3817 } // namespace internal
3818 } // namespace v8 3818 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/scavenge-job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698