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

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

Issue 1410163005: [heap] Use live memory as heuristic for spawning compaction tasks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added comment Created 5 years, 1 month 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 | « no previous file | no next file » | 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 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 } 3304 }
3305 p->ResetLiveBytes(); 3305 p->ResetLiveBytes();
3306 return true; 3306 return true;
3307 } 3307 }
3308 3308
3309 3309
3310 int MarkCompactCollector::NumberOfParallelCompactionTasks() { 3310 int MarkCompactCollector::NumberOfParallelCompactionTasks() {
3311 if (!FLAG_parallel_compaction) return 1; 3311 if (!FLAG_parallel_compaction) return 1;
3312 // We cap the number of parallel compaction tasks by 3312 // We cap the number of parallel compaction tasks by
3313 // - (#cores - 1) 3313 // - (#cores - 1)
3314 // - a value depending on the list of evacuation candidates 3314 // - a value depending on the live memory in evacuation candidates
3315 // - a hard limit 3315 // - a hard limit
3316 const int kPagesPerCompactionTask = 4; 3316 //
3317 // TODO(mlippautz): Instead of basing the limit on live memory, we could also
3318 // compute the number from the time it takes to evacuate memory and a given
3319 // desired time in which compaction should be finished.
3320 const int kLiveMemoryPerCompactionTask = 2 * Page::kPageSize;
3317 const int kMaxCompactionTasks = 8; 3321 const int kMaxCompactionTasks = 8;
3322 int live_bytes = 0;
3323 for (Page* page : evacuation_candidates_) {
3324 live_bytes += page->LiveBytes();
3325 }
3318 return Min(kMaxCompactionTasks, 3326 return Min(kMaxCompactionTasks,
3319 Min(1 + evacuation_candidates_.length() / kPagesPerCompactionTask, 3327 Min(1 + live_bytes / kLiveMemoryPerCompactionTask,
3320 Max(1, base::SysInfo::NumberOfProcessors() - 1))); 3328 Max(1, base::SysInfo::NumberOfProcessors() - 1)));
3321 } 3329 }
3322 3330
3323 3331
3324 void MarkCompactCollector::EvacuatePagesInParallel() { 3332 void MarkCompactCollector::EvacuatePagesInParallel() {
3325 const int num_pages = evacuation_candidates_.length(); 3333 const int num_pages = evacuation_candidates_.length();
3326 if (num_pages == 0) return; 3334 if (num_pages == 0) return;
3327 3335
3328 const int num_tasks = NumberOfParallelCompactionTasks(); 3336 const int num_tasks = NumberOfParallelCompactionTasks();
3329 3337
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 MarkBit mark_bit = Marking::MarkBitFrom(host); 4600 MarkBit mark_bit = Marking::MarkBitFrom(host);
4593 if (Marking::IsBlack(mark_bit)) { 4601 if (Marking::IsBlack(mark_bit)) {
4594 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); 4602 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host);
4595 RecordRelocSlot(&rinfo, target); 4603 RecordRelocSlot(&rinfo, target);
4596 } 4604 }
4597 } 4605 }
4598 } 4606 }
4599 4607
4600 } // namespace internal 4608 } // namespace internal
4601 } // namespace v8 4609 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698