1 /* 2 * Copyright (c) 2013, 2015, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/shared/gcPolicyCounters.hpp" 26 #include "gc/shenandoah/shenandoahCollectionSet.hpp" 27 #include "gc/shenandoah/shenandoahFreeSet.hpp" 28 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" 29 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 30 #include "gc/shenandoah/shenandoahPartialGC.hpp" 31 #include "gc/shenandoah/shenandoahPhaseTimes.hpp" 32 #include "runtime/os.hpp" 33 34 class ShenandoahHeuristics : public CHeapObj<mtGC> { 35 36 NumberSeq _allocation_rate_bytes; 37 NumberSeq _reclamation_rate_bytes; 38 39 size_t _bytes_allocated_since_CM; 40 size_t _bytes_reclaimed_this_cycle; 41 42 protected: 43 typedef struct { 44 size_t region_number; 45 size_t garbage; 46 } RegionGarbage; 47 48 static int compare_by_garbage(RegionGarbage a, RegionGarbage b) { 49 if (a.garbage > b.garbage) 50 return -1; 51 else if (b.garbage < a.garbage) 52 return 1; 53 else return 0; 54 } 55 56 RegionGarbage* get_region_garbage_cache(size_t num) { 57 RegionGarbage* res = _region_garbage; 58 if (res == NULL) { 59 res = NEW_C_HEAP_ARRAY(RegionGarbage, num, mtGC); 60 _region_garbage_size = num; 61 } else if (_region_garbage_size < num) { 62 REALLOC_C_HEAP_ARRAY(RegionGarbage, _region_garbage, num, mtGC); 63 _region_garbage_size = num; 64 } 65 return res; 66 } 67 68 RegionGarbage* _region_garbage; 69 size_t _region_garbage_size; 70 71 size_t _bytes_allocated_start_CM; 72 size_t _bytes_allocated_during_CM; 73 74 size_t _bytes_allocated_after_last_gc; 75 76 uint _cancelled_cm_cycles_in_a_row; 77 uint _successful_cm_cycles_in_a_row; 78 79 size_t _bytes_in_cset; 80 81 public: 82 83 ShenandoahHeuristics(); 84 ~ShenandoahHeuristics(); 85 86 void record_bytes_allocated(size_t bytes); 87 void record_bytes_reclaimed(size_t bytes); 88 void record_bytes_start_CM(size_t bytes); 89 void record_bytes_end_CM(size_t bytes); 90 91 void record_gc_start() { 92 // Do nothing. 93 } 94 95 void record_gc_end() { 96 _bytes_allocated_after_last_gc = ShenandoahHeap::heap()->used(); 97 } 98 99 size_t bytes_in_cset() const { return _bytes_in_cset; } 100 101 virtual void print_thresholds() { 102 } 103 104 virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const=0; 105 106 virtual bool update_refs_early() { 107 return ShenandoahUpdateRefsEarly; 108 } 109 110 virtual bool should_start_partial_gc() { 111 return false; 112 } 113 114 virtual bool handover_cancelled_marking() { 115 return _cancelled_cm_cycles_in_a_row <= ShenandoahFullGCThreshold; 116 } 117 118 virtual void record_cm_cancelled() { 119 _cancelled_cm_cycles_in_a_row++; 120 _successful_cm_cycles_in_a_row = 0; 121 } 122 123 virtual void record_cm_success() { 124 _cancelled_cm_cycles_in_a_row = 0; 125 _successful_cm_cycles_in_a_row++; 126 } 127 128 virtual void record_full_gc() { 129 _bytes_in_cset = 0; 130 } 131 132 virtual void start_choose_collection_set() { 133 } 134 virtual void end_choose_collection_set() { 135 } 136 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) = 0; 137 138 virtual void choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections=NULL); 139 virtual void choose_free_set(ShenandoahFreeSet* free_set); 140 141 virtual bool process_references() { 142 if (ShenandoahRefProcFrequency == 0) return false; 143 size_t cycle = ShenandoahHeap::heap()->shenandoahPolicy()->cycle_counter(); 144 // Process references every Nth GC cycle. 145 return cycle % ShenandoahRefProcFrequency == 0; 146 } 147 148 virtual bool unload_classes() { 149 if (ShenandoahUnloadClassesFrequency == 0) return false; 150 size_t cycle = ShenandoahHeap::heap()->shenandoahPolicy()->cycle_counter(); 151 // Unload classes every Nth GC cycle. 152 // This should not happen in the same cycle as process_references to amortize costs. 153 // Offsetting by one is enough to break the rendezvous when periods are equal. 154 // When periods are not equal, offsetting by one is just as good as any other guess. 155 return (cycle + 1) % ShenandoahUnloadClassesFrequency == 0; 156 } 157 158 virtual bool needs_regions_sorted_by_garbage() { 159 // Most of them do not. 160 return false; 161 } 162 }; 163 164 ShenandoahHeuristics::ShenandoahHeuristics() : 165 _bytes_allocated_since_CM(0), 166 _bytes_reclaimed_this_cycle(0), 167 _bytes_allocated_start_CM(0), 168 _bytes_allocated_during_CM(0), 169 _bytes_allocated_after_last_gc(0), 170 _bytes_in_cset(0), 171 _cancelled_cm_cycles_in_a_row(0), 172 _successful_cm_cycles_in_a_row(0), 173 _region_garbage(NULL), 174 _region_garbage_size(0) 175 { 176 } 177 178 ShenandoahHeuristics::~ShenandoahHeuristics() { 179 if (_region_garbage != NULL) { 180 FREE_C_HEAP_ARRAY(RegionGarbage, _region_garbage); 181 } 182 } 183 184 void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) { 185 start_choose_collection_set(); 186 187 ShenandoahHeap* heap = ShenandoahHeap::heap(); 188 189 // Poll this before populating collection set. 190 size_t total_garbage = heap->garbage(); 191 192 // Step 1. Build up the region candidates we care about, rejecting losers and accepting winners right away. 193 194 ShenandoahHeapRegionSet* regions = heap->regions(); 195 size_t active = regions->active_regions(); 196 197 RegionGarbage* candidates = get_region_garbage_cache(active); 198 199 size_t cand_idx = 0; 200 _bytes_in_cset = 0; 201 202 size_t immediate_garbage = 0; 203 size_t immediate_regions = 0; 204 for (size_t i = 0; i < active; i++) { 205 ShenandoahHeapRegion* region = regions->get(i); 206 207 if (! region->is_humongous() && ! region->is_pinned()) { 208 if ((! region->is_empty()) && ! region->has_live()) { 209 // We can recycle it right away and put it in the free set. 210 immediate_regions++; 211 immediate_garbage += region->garbage(); 212 heap->decrease_used(region->used()); 213 region->recycle(); 214 log_develop_trace(gc)("Choose region " SIZE_FORMAT " for immediate reclaim with garbage = " SIZE_FORMAT 215 " and live = " SIZE_FORMAT "\n", 216 region->region_number(), region->garbage(), region->get_live_data_bytes()); 217 } else { 218 // This is our candidate for later consideration. 219 candidates[cand_idx].region_number = region->region_number(); 220 candidates[cand_idx].garbage = region->garbage(); 221 cand_idx++; 222 } 223 } else { 224 assert(region->has_live() || region->is_empty() || region->is_pinned() || region->is_humongous(), "check rejected"); 225 log_develop_trace(gc)("Rejected region " SIZE_FORMAT " with garbage = " SIZE_FORMAT 226 " and live = " SIZE_FORMAT "\n", 227 region->region_number(), region->garbage(), region->get_live_data_bytes()); 228 } 229 } 230 231 // Step 2. Process the remanining candidates, if any. 232 233 if (cand_idx > 0) { 234 if (needs_regions_sorted_by_garbage()) { 235 QuickSort::sort<RegionGarbage>(candidates, (int)cand_idx, compare_by_garbage, false); 236 } 237 238 for (size_t i = 0; i < cand_idx; i++) { 239 ShenandoahHeapRegion *region = regions->get_fast(candidates[i].region_number); 240 if (region_in_collection_set(region, immediate_garbage)) { 241 log_develop_trace(gc)("Choose region " SIZE_FORMAT " with garbage = " SIZE_FORMAT 242 " and live = " SIZE_FORMAT "\n", 243 region->region_number(), region->garbage(), region->get_live_data_bytes()); 244 collection_set->add_region(region); 245 region->set_in_collection_set(true); 246 _bytes_in_cset += region->used(); 247 } 248 } 249 } 250 251 end_choose_collection_set(); 252 253 log_info(gc, ergo)("Total Garbage: "SIZE_FORMAT"M", 254 total_garbage / M); 255 log_info(gc, ergo)("Immediate Garbage: "SIZE_FORMAT"M, "SIZE_FORMAT" regions", 256 immediate_garbage / M, immediate_regions); 257 log_info(gc, ergo)("Garbage to be collected: "SIZE_FORMAT"M ("SIZE_FORMAT"%% of total), "SIZE_FORMAT" regions", 258 collection_set->garbage() / M, collection_set->garbage() * 100 / MAX2(total_garbage, (size_t)1), collection_set->count()); 259 log_info(gc, ergo)("Live objects to be evacuated: "SIZE_FORMAT"M", 260 collection_set->live_data() / M); 261 log_info(gc, ergo)("Live/garbage ratio in collected regions: "SIZE_FORMAT"%%", 262 collection_set->live_data() * 100 / MAX2(collection_set->garbage(), (size_t)1)); 263 } 264 265 void ShenandoahHeuristics::choose_free_set(ShenandoahFreeSet* free_set) { 266 267 ShenandoahHeapRegionSet* ordered_regions = ShenandoahHeap::heap()->regions(); 268 size_t i = 0; 269 size_t end = ordered_regions->active_regions(); 270 271 ShenandoahHeap* heap = ShenandoahHeap::heap(); 272 while (i < end) { 273 ShenandoahHeapRegion* region = ordered_regions->get(i++); 274 if ((! heap->in_collection_set(region)) 275 && (! region->is_humongous()) 276 && (! region->is_pinned())) { 277 free_set->add_region(region); 278 } 279 } 280 } 281 282 void ShenandoahCollectorPolicy::record_workers_start(TimingPhase phase) { 283 for (uint i = 0; i < ShenandoahPhaseTimes::GCParPhasesSentinel; i++) { 284 _phase_times->reset(i); 285 } 286 } 287 288 void ShenandoahCollectorPolicy::record_workers_end(TimingPhase phase) { 289 if (phase != _num_phases) { 290 for (uint i = 0; i < ShenandoahPhaseTimes::GCParPhasesSentinel; i++) { 291 double t = _phase_times->average(i); 292 _timing_data[phase + i]._secs.add(t); 293 } 294 } 295 } 296 297 void ShenandoahCollectorPolicy::record_phase_start(TimingPhase phase) { 298 _timing_data[phase]._start = os::elapsedTime(); 299 300 } 301 302 void ShenandoahCollectorPolicy::record_phase_end(TimingPhase phase) { 303 double end = os::elapsedTime(); 304 double elapsed = end - _timing_data[phase]._start; 305 _timing_data[phase]._secs.add(elapsed); 306 } 307 308 void ShenandoahCollectorPolicy::record_gc_start() { 309 _heuristics->record_gc_start(); 310 } 311 312 void ShenandoahCollectorPolicy::record_gc_end() { 313 _heuristics->record_gc_end(); 314 } 315 316 void ShenandoahCollectorPolicy::report_concgc_cancelled() { 317 } 318 319 void ShenandoahHeuristics::record_bytes_allocated(size_t bytes) { 320 _bytes_allocated_since_CM = bytes; 321 _bytes_allocated_start_CM = bytes; 322 _allocation_rate_bytes.add(bytes); 323 } 324 325 void ShenandoahHeuristics::record_bytes_reclaimed(size_t bytes) { 326 _bytes_reclaimed_this_cycle = bytes; 327 _reclamation_rate_bytes.add(bytes); 328 } 329 330 void ShenandoahHeuristics::record_bytes_start_CM(size_t bytes) { 331 _bytes_allocated_start_CM = bytes; 332 } 333 334 void ShenandoahHeuristics::record_bytes_end_CM(size_t bytes) { 335 _bytes_allocated_during_CM = (bytes > _bytes_allocated_start_CM) ? (bytes - _bytes_allocated_start_CM) 336 : bytes; 337 } 338 339 class PassiveHeuristics : public ShenandoahHeuristics { 340 public: 341 PassiveHeuristics() : ShenandoahHeuristics() { 342 } 343 344 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 345 return r->garbage() > 0; 346 } 347 348 virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const { 349 // Never do concurrent GCs. 350 return false; 351 } 352 353 virtual bool process_references() { 354 // Randomly process refs with 50% chance. 355 return (os::random() & 1) == 1; 356 } 357 358 virtual bool unload_classes() { 359 // Randomly unload classes with 50% chance. 360 return (os::random() & 1) == 1; 361 } 362 }; 363 364 class AggressiveHeuristics : public ShenandoahHeuristics { 365 public: 366 AggressiveHeuristics() : ShenandoahHeuristics() { 367 } 368 369 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 370 return r->garbage() > 0; 371 } 372 373 virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const { 374 return true; 375 } 376 377 virtual bool process_references() { 378 // Randomly process refs with 50% chance. 379 return (os::random() & 1) == 1; 380 } 381 382 virtual bool unload_classes() { 383 // Randomly unload classes with 50% chance. 384 return (os::random() & 1) == 1; 385 } 386 }; 387 388 class DynamicHeuristics : public ShenandoahHeuristics { 389 public: 390 DynamicHeuristics() : ShenandoahHeuristics() { 391 } 392 393 void print_thresholds() { 394 log_info(gc, init)("Shenandoah heuristics thresholds: allocation "SIZE_FORMAT", free "SIZE_FORMAT", garbage "SIZE_FORMAT, 395 ShenandoahAllocationThreshold, 396 ShenandoahFreeThreshold, 397 ShenandoahGarbageThreshold); 398 } 399 400 virtual ~DynamicHeuristics() {} 401 402 virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const { 403 404 bool shouldStartConcurrentMark = false; 405 406 ShenandoahHeap* heap = ShenandoahHeap::heap(); 407 size_t free_capacity = heap->free_regions()->capacity(); 408 size_t free_used = heap->free_regions()->used(); 409 assert(free_used <= free_capacity, "must use less than capacity"); 410 size_t cset = MIN2(_bytes_in_cset, (ShenandoahCSetThreshold * capacity) / 100); 411 size_t available = free_capacity - free_used + cset; 412 uintx threshold = ShenandoahFreeThreshold + ShenandoahCSetThreshold; 413 size_t targetStartMarking = (capacity * threshold) / 100; 414 415 size_t threshold_bytes_allocated = heap->capacity() * ShenandoahAllocationThreshold / 100; 416 if (available < targetStartMarking && 417 heap->bytes_allocated_since_cm() > threshold_bytes_allocated) 418 { 419 // Need to check that an appropriate number of regions have 420 // been allocated since last concurrent mark too. 421 shouldStartConcurrentMark = true; 422 } 423 424 return shouldStartConcurrentMark; 425 } 426 427 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 428 size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100; 429 return r->garbage() > threshold; 430 } 431 432 }; 433 434 435 class AdaptiveHeuristics : public ShenandoahHeuristics { 436 private: 437 uintx _free_threshold; 438 TruncatedSeq* _cset_history; 439 440 public: 441 AdaptiveHeuristics() : 442 ShenandoahHeuristics(), 443 _free_threshold(ShenandoahInitFreeThreshold), 444 _cset_history(new TruncatedSeq((uint)ShenandoahHappyCyclesThreshold)) { 445 446 _cset_history->add((double) ShenandoahCSetThreshold); 447 _cset_history->add((double) ShenandoahCSetThreshold); 448 } 449 450 virtual ~AdaptiveHeuristics() { 451 delete _cset_history; 452 } 453 454 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 455 size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100; 456 return r->garbage() > threshold; 457 } 458 459 virtual void record_cm_cancelled() { 460 ShenandoahHeuristics::record_cm_cancelled(); 461 if (_free_threshold < ShenandoahMaxFreeThreshold) { 462 _free_threshold++; 463 log_info(gc,ergo)("increasing free threshold to: "UINTX_FORMAT, _free_threshold); 464 } 465 } 466 467 virtual void record_cm_success() { 468 ShenandoahHeuristics::record_cm_success(); 469 if (_successful_cm_cycles_in_a_row > ShenandoahHappyCyclesThreshold && 470 _free_threshold > ShenandoahMinFreeThreshold) { 471 _free_threshold--; 472 log_info(gc,ergo)("reducing free threshold to: "UINTX_FORMAT, _free_threshold); 473 _successful_cm_cycles_in_a_row = 0; 474 } 475 } 476 477 virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const { 478 bool shouldStartConcurrentMark = false; 479 480 ShenandoahHeap* heap = ShenandoahHeap::heap(); 481 size_t free_capacity = heap->free_regions()->capacity(); 482 size_t free_used = heap->free_regions()->used(); 483 assert(free_used <= free_capacity, "must use less than capacity"); 484 // size_t cset_threshold = (size_t) _cset_history->maximum(); 485 size_t cset_threshold = (size_t) _cset_history->davg(); 486 size_t cset = MIN2(_bytes_in_cset, (cset_threshold * capacity) / 100); 487 size_t available = free_capacity - free_used + cset; 488 uintx factor = _free_threshold + cset_threshold; 489 size_t targetStartMarking = (capacity * factor) / 100; 490 491 size_t threshold_bytes_allocated = heap->capacity() * ShenandoahAllocationThreshold / 100; 492 if (available < targetStartMarking && 493 heap->bytes_allocated_since_cm() > threshold_bytes_allocated) 494 { 495 // Need to check that an appropriate number of regions have 496 // been allocated since last concurrent mark too. 497 shouldStartConcurrentMark = true; 498 } 499 500 if (shouldStartConcurrentMark) { 501 log_info(gc,ergo)("predicted cset threshold: "SIZE_FORMAT, cset_threshold); 502 log_info(gc,ergo)("Starting concurrent mark at "SIZE_FORMAT"K CSet ("SIZE_FORMAT"%%)", _bytes_in_cset / K, _bytes_in_cset * 100 / capacity); 503 _cset_history->add((double) (_bytes_in_cset * 100 / capacity)); 504 } 505 return shouldStartConcurrentMark; 506 } 507 508 }; 509 510 class GlobalHeuristics : public DynamicHeuristics { 511 private: 512 size_t _garbage; 513 size_t _min_garbage; 514 public: 515 GlobalHeuristics() : DynamicHeuristics() { 516 if (FLAG_IS_DEFAULT(ShenandoahGarbageThreshold)) { 517 FLAG_SET_DEFAULT(ShenandoahGarbageThreshold, 90); 518 } 519 } 520 virtual ~GlobalHeuristics() {} 521 522 virtual void start_choose_collection_set() { 523 _garbage = 0; 524 size_t heap_garbage = ShenandoahHeap::heap()->garbage(); 525 _min_garbage = heap_garbage * ShenandoahGarbageThreshold / 100; 526 } 527 528 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 529 if (_garbage + immediate_garbage < _min_garbage && ! r->is_empty()) { 530 _garbage += r->garbage(); 531 return true; 532 } else { 533 return false; 534 } 535 } 536 537 virtual bool needs_regions_sorted_by_garbage() { 538 return true; 539 } 540 }; 541 542 class RatioHeuristics : public DynamicHeuristics { 543 private: 544 size_t _garbage; 545 size_t _live; 546 public: 547 RatioHeuristics() : DynamicHeuristics() { 548 if (FLAG_IS_DEFAULT(ShenandoahGarbageThreshold)) { 549 FLAG_SET_DEFAULT(ShenandoahGarbageThreshold, 95); 550 } 551 } 552 virtual ~RatioHeuristics() {} 553 554 virtual void start_choose_collection_set() { 555 _garbage = 0; 556 _live = 0; 557 } 558 559 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 560 size_t min_ratio = 100 - ShenandoahGarbageThreshold; 561 if (_live * 100 / MAX2(_garbage + immediate_garbage, (size_t)1) < min_ratio && ! r->is_empty()) { 562 _garbage += r->garbage(); 563 _live += r->get_live_data_bytes(); 564 return true; 565 } else { 566 return false; 567 } 568 } 569 570 virtual bool needs_regions_sorted_by_garbage() { 571 return true; 572 } 573 }; 574 575 class ConnectionHeuristics : public ShenandoahHeuristics { 576 private: 577 size_t _max_live_data; 578 double _used_threshold_factor; 579 double _garbage_threshold_factor; 580 double _allocation_threshold_factor; 581 582 uintx _used_threshold; 583 uintx _garbage_threshold; 584 uintx _allocation_threshold; 585 586 public: 587 ConnectionHeuristics() : ShenandoahHeuristics() { 588 _max_live_data = 0; 589 590 _used_threshold = 0; 591 _garbage_threshold = 0; 592 _allocation_threshold = 0; 593 594 _used_threshold_factor = 0.; 595 _garbage_threshold_factor = 0.1; 596 _allocation_threshold_factor = 0.; 597 } 598 599 virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const { 600 size_t half_gig = 64 * 1024 * 1024; 601 size_t bytes_alloc = ShenandoahHeap::heap()->bytes_allocated_since_cm(); 602 bool result = bytes_alloc > half_gig; 603 if (result) tty->print("Starting a concurrent mark"); 604 return result; 605 } 606 607 bool maybe_add_heap_region(ShenandoahHeapRegion* hr, ShenandoahCollectionSet* collection_set) { 608 if (!hr->is_humongous() && hr->has_live() && !collection_set->contains(hr)) { 609 collection_set->add_region_check_for_duplicates(hr); 610 hr->set_in_collection_set(true); 611 return true; 612 } 613 return false; 614 } 615 616 virtual void choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) { 617 ShenandoahHeapRegionSet* regions = ShenandoahHeap::heap()->regions(); 618 size_t active = regions->active_regions(); 619 620 RegionGarbage* sorted_by_garbage = get_region_garbage_cache(active); 621 for (size_t i = 0; i < active; i++) { 622 ShenandoahHeapRegion* r = regions->get_fast(i); 623 sorted_by_garbage[i].region_number = r->region_number(); 624 sorted_by_garbage[i].garbage = r->garbage(); 625 } 626 627 QuickSort::sort<RegionGarbage>(sorted_by_garbage, (int) active, compare_by_garbage, false); 628 629 size_t num = ShenandoahHeap::heap()->num_regions(); 630 // simulate write heuristics by picking best region. 631 int r = 0; 632 ShenandoahHeapRegion* choosenOne = regions->get(sorted_by_garbage[0].region_number); 633 634 while (! maybe_add_heap_region(choosenOne, collection_set)) { 635 choosenOne = regions->get(sorted_by_garbage[++r].region_number); 636 } 637 638 size_t region_number = choosenOne->region_number(); 639 log_develop_trace(gc)("Adding choosen region " SIZE_FORMAT, region_number); 640 641 // Add all the regions which point to this region. 642 for (size_t i = 0; i < num; i++) { 643 if (connections[i * num + region_number] > 0) { 644 ShenandoahHeapRegion* candidate = regions->get(sorted_by_garbage[i].region_number); 645 if (maybe_add_heap_region(candidate, collection_set)) { 646 log_develop_trace(gc)("Adding region " SIZE_FORMAT " which points to the choosen region", i); 647 } 648 } 649 } 650 651 // Add all the regions they point to. 652 for (size_t ci = 0; ci < collection_set->active_regions(); ci++) { 653 ShenandoahHeapRegion* cs_heap_region = collection_set->get(ci); 654 size_t cs_heap_region_number = cs_heap_region->region_number(); 655 for (size_t i = 0; i < num; i++) { 656 if (connections[i * num + cs_heap_region_number] > 0) { 657 ShenandoahHeapRegion* candidate = regions->get(sorted_by_garbage[i].region_number); 658 if (maybe_add_heap_region(candidate, collection_set)) { 659 log_develop_trace(gc) 660 ("Adding region " SIZE_FORMAT " which is pointed to by region " SIZE_FORMAT, i, cs_heap_region_number); 661 } 662 } 663 } 664 } 665 _max_live_data = MAX2(_max_live_data, collection_set->live_data()); 666 collection_set->print(); 667 } 668 669 virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) { 670 assert(false, "Shouldn't get here"); 671 return false; 672 } 673 }; 674 class PartialHeuristics : public AdaptiveHeuristics { 675 public: 676 PartialHeuristics() : AdaptiveHeuristics() { 677 if (FLAG_IS_DEFAULT(ShenandoahAllocationThreshold)) { 678 FLAG_SET_DEFAULT(ShenandoahAllocationThreshold, 5); 679 } 680 FLAG_SET_DEFAULT(UseShenandoahMatrix, true); 681 // TODO: Disable this optimization for now, as it also requires the matrix barriers. 682 FLAG_SET_DEFAULT(ArrayCopyLoadStoreMaxElem, 0); 683 } 684 685 virtual ~PartialHeuristics() {} 686 687 bool update_refs_early() { 688 return true; 689 } 690 691 bool should_start_partial_gc() { 692 ShenandoahHeap* heap = ShenandoahHeap::heap(); 693 size_t capacity = heap->capacity(); 694 695 size_t used = heap->used(); 696 return (used - _bytes_allocated_after_last_gc) * 100 / capacity > ShenandoahAllocationThreshold; 697 } 698 }; 699 700 ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() : 701 _cycle_counter(0), 702 _successful_cm(0), 703 _degenerated_cm(0) 704 { 705 706 ShenandoahHeapRegion::setup_heap_region_size(initial_heap_byte_size(), max_heap_byte_size()); 707 708 initialize_all(); 709 710 _tracer = new (ResourceObj::C_HEAP, mtGC) ShenandoahTracer(); 711 _stw_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer(); 712 _conc_timer = new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer(); 713 _user_requested_gcs = 0; 714 _allocation_failure_gcs = 0; 715 _conc_gc_aborted = false; 716 717 _phase_names[total_pause] = "Total Pauses (net)"; 718 _phase_names[total_pause_gross] = "Total Pauses (gross)"; 719 _phase_names[init_mark] = "Initial Mark Pauses (net)"; 720 _phase_names[init_mark_gross] = "Initial Mark Pauses (gross)"; 721 _phase_names[final_mark] = "Final Mark Pauses (net)"; 722 _phase_names[final_mark_gross] = "Final Mark Pauses (gross)"; 723 _phase_names[accumulate_stats] = " Accumulate Stats"; 724 _phase_names[make_parsable] = " Make Parsable"; 725 _phase_names[clear_liveness] = " Clear Liveness"; 726 _phase_names[scan_roots] = " Scan Roots"; 727 _phase_names[update_roots] = " Update Roots"; 728 _phase_names[drain_satb] = " Drain SATB"; 729 _phase_names[weakrefs] = " Weak References"; 730 _phase_names[class_unloading] = " Class Unloading"; 731 _phase_names[prepare_evac] = " Prepare Evacuation"; 732 _phase_names[init_evac] = " Initial Evacuation"; 733 734 _phase_names[scan_thread_roots] = " S: Thread Roots"; 735 _phase_names[scan_code_roots] = " S: Code Cache Roots"; 736 _phase_names[scan_string_table_roots] = " S: String Table Roots"; 737 _phase_names[scan_universe_roots] = " S: Universe Roots"; 738 _phase_names[scan_jni_roots] = " S: JNI Roots"; 739 _phase_names[scan_jni_weak_roots] = " S: JNI Weak Roots"; 740 _phase_names[scan_synchronizer_roots] = " S: Synchronizer Roots"; 741 _phase_names[scan_flat_profiler_roots] = " S: Flat Profiler Roots"; 742 _phase_names[scan_management_roots] = " S: Management Roots"; 743 _phase_names[scan_system_dictionary_roots] = " S: System Dict Roots"; 744 _phase_names[scan_cldg_roots] = " S: CLDG Roots"; 745 _phase_names[scan_jvmti_roots] = " S: JVMTI Roots"; 746 747 _phase_names[update_thread_roots] = " U: Thread Roots"; 748 _phase_names[update_code_roots] = " U: Code Cache Roots"; 749 _phase_names[update_string_table_roots] = " U: String Table Roots"; 750 _phase_names[update_universe_roots] = " U: Universe Roots"; 751 _phase_names[update_jni_roots] = " U: JNI Roots"; 752 _phase_names[update_jni_weak_roots] = " U: JNI Weak Roots"; 753 _phase_names[update_synchronizer_roots] = " U: Synchronizer Roots"; 754 _phase_names[update_flat_profiler_roots] = " U: Flat Profiler Roots"; 755 _phase_names[update_management_roots] = " U: Management Roots"; 756 _phase_names[update_system_dictionary_roots] = " U: System Dict Roots"; 757 _phase_names[update_cldg_roots] = " U: CLDG Roots"; 758 _phase_names[update_jvmti_roots] = " U: JVMTI Roots"; 759 760 _phase_names[evac_thread_roots] = " E: Thread Roots"; 761 _phase_names[evac_code_roots] = " E: Code Cache Roots"; 762 _phase_names[evac_string_table_roots] = " E: String Table Roots"; 763 _phase_names[evac_universe_roots] = " E: Universe Roots"; 764 _phase_names[evac_jni_roots] = " E: JNI Roots"; 765 _phase_names[evac_jni_weak_roots] = " E: JNI Weak Roots"; 766 _phase_names[evac_synchronizer_roots] = " E: Synchronizer Roots"; 767 _phase_names[evac_flat_profiler_roots] = " E: Flat Profiler Roots"; 768 _phase_names[evac_management_roots] = " E: Management Roots"; 769 _phase_names[evac_system_dictionary_roots] = " E: System Dict Roots"; 770 _phase_names[evac_cldg_roots] = " E: CLDG Roots"; 771 _phase_names[evac_jvmti_roots] = " E: JVMTI Roots"; 772 773 _phase_names[recycle_regions] = " Recycle regions"; 774 _phase_names[reset_bitmaps] = "Reset Bitmaps"; 775 _phase_names[resize_tlabs] = "Resize TLABs"; 776 777 _phase_names[full_gc] = "Full GC"; 778 _phase_names[full_gc_heapdumps] = " Heap Dumps"; 779 _phase_names[full_gc_prepare] = " Prepare"; 780 _phase_names[full_gc_mark] = " Mark"; 781 _phase_names[full_gc_mark_drain_queues] = " Drain Queues"; 782 _phase_names[full_gc_mark_weakrefs] = " Weak References"; 783 _phase_names[full_gc_mark_class_unloading] = " Class Unloading"; 784 _phase_names[full_gc_calculate_addresses] = " Calculate Addresses"; 785 _phase_names[full_gc_adjust_pointers] = " Adjust Pointers"; 786 _phase_names[full_gc_copy_objects] = " Copy Objects"; 787 788 _phase_names[partial_gc] = "Partial GC"; 789 _phase_names[conc_mark] = "Concurrent Marking"; 790 _phase_names[conc_evac] = "Concurrent Evacuation"; 791 792 _phase_names[conc_update_refs] = "Concurrent Update References"; 793 _phase_names[pre_update_refs] = "Pause Pre Update References"; 794 _phase_names[post_update_refs] = "Pause Post Update References"; 795 796 if (ShenandoahGCHeuristics != NULL) { 797 if (strcmp(ShenandoahGCHeuristics, "aggressive") == 0) { 798 log_info(gc, init)("Shenandoah heuristics: aggressive"); 799 _heuristics = new AggressiveHeuristics(); 800 } else if (strcmp(ShenandoahGCHeuristics, "dynamic") == 0) { 801 log_info(gc, init)("Shenandoah heuristics: dynamic"); 802 _heuristics = new DynamicHeuristics(); 803 } else if (strcmp(ShenandoahGCHeuristics, "global") == 0) { 804 log_info(gc, init)("Shenandoah heuristics: global"); 805 _heuristics = new GlobalHeuristics(); 806 } else if (strcmp(ShenandoahGCHeuristics, "ratio") == 0) { 807 log_info(gc, init)("Shenandoah heuristics: ratio"); 808 _heuristics = new RatioHeuristics(); 809 } else if (strcmp(ShenandoahGCHeuristics, "adaptive") == 0) { 810 log_info(gc, init)("Shenandoah heuristics: adaptive"); 811 _heuristics = new AdaptiveHeuristics(); 812 } else if (strcmp(ShenandoahGCHeuristics, "passive") == 0) { 813 log_info(gc, init)("Shenandoah heuristics: passive"); 814 _heuristics = new PassiveHeuristics(); 815 } else if (strcmp(ShenandoahGCHeuristics, "connections") == 0) { 816 log_info(gc, init)("Shenandoah heuristics: connections"); 817 _heuristics = new ConnectionHeuristics(); 818 } else if (strcmp(ShenandoahGCHeuristics, "partial") == 0) { 819 log_info(gc, init)("Shenandoah heuristics: partial GC"); 820 _heuristics = new PartialHeuristics(); 821 } else { 822 vm_exit_during_initialization("Unknown -XX:ShenandoahGCHeuristics option"); 823 } 824 _heuristics->print_thresholds(); 825 } else { 826 ShouldNotReachHere(); 827 } 828 _phase_times = new ShenandoahPhaseTimes(MAX2(ConcGCThreads, ParallelGCThreads)); 829 } 830 831 ShenandoahCollectorPolicy* ShenandoahCollectorPolicy::as_pgc_policy() { 832 return this; 833 } 834 835 BarrierSet::Name ShenandoahCollectorPolicy::barrier_set_name() { 836 return BarrierSet::ShenandoahBarrierSet; 837 } 838 839 HeapWord* ShenandoahCollectorPolicy::mem_allocate_work(size_t size, 840 bool is_tlab, 841 bool* gc_overhead_limit_was_exceeded) { 842 guarantee(false, "Not using this policy feature yet."); 843 return NULL; 844 } 845 846 HeapWord* ShenandoahCollectorPolicy::satisfy_failed_allocation(size_t size, bool is_tlab) { 847 guarantee(false, "Not using this policy feature yet."); 848 return NULL; 849 } 850 851 void ShenandoahCollectorPolicy::initialize_alignments() { 852 853 // This is expected by our algorithm for ShenandoahHeap::heap_region_containing(). 854 _space_alignment = ShenandoahHeapRegion::region_size_bytes(); 855 _heap_alignment = ShenandoahHeapRegion::region_size_bytes(); 856 } 857 858 void ShenandoahCollectorPolicy::post_heap_initialize() { 859 // Nothing to do here (yet). 860 } 861 862 void ShenandoahCollectorPolicy::record_bytes_allocated(size_t bytes) { 863 _heuristics->record_bytes_allocated(bytes); 864 } 865 866 void ShenandoahCollectorPolicy::record_bytes_start_CM(size_t bytes) { 867 _heuristics->record_bytes_start_CM(bytes); 868 } 869 870 void ShenandoahCollectorPolicy::record_bytes_end_CM(size_t bytes) { 871 _heuristics->record_bytes_end_CM(bytes); 872 } 873 874 void ShenandoahCollectorPolicy::record_bytes_reclaimed(size_t bytes) { 875 _heuristics->record_bytes_reclaimed(bytes); 876 } 877 878 void ShenandoahCollectorPolicy::record_user_requested_gc() { 879 _user_requested_gcs++; 880 } 881 882 void ShenandoahCollectorPolicy::record_allocation_failure_gc() { 883 _allocation_failure_gcs++; 884 } 885 886 bool ShenandoahCollectorPolicy::should_start_concurrent_mark(size_t used, 887 size_t capacity) { 888 return _heuristics->should_start_concurrent_mark(used, capacity); 889 } 890 891 bool ShenandoahCollectorPolicy::handover_cancelled_marking() { 892 return _heuristics->handover_cancelled_marking(); 893 } 894 895 bool ShenandoahCollectorPolicy::update_refs_early() { 896 return _heuristics->update_refs_early(); 897 } 898 899 void ShenandoahCollectorPolicy::record_cm_success() { 900 _heuristics->record_cm_success(); 901 _successful_cm++; 902 } 903 904 void ShenandoahCollectorPolicy::record_cm_degenerated() { 905 _degenerated_cm++; 906 } 907 908 void ShenandoahCollectorPolicy::record_cm_cancelled() { 909 _heuristics->record_cm_cancelled(); 910 } 911 912 void ShenandoahCollectorPolicy::record_full_gc() { 913 _heuristics->record_full_gc(); 914 } 915 916 void ShenandoahCollectorPolicy::choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) { 917 _heuristics->choose_collection_set(collection_set, connections); 918 } 919 920 void ShenandoahCollectorPolicy::choose_free_set(ShenandoahFreeSet* free_set) { 921 _heuristics->choose_free_set(free_set); 922 } 923 924 925 bool ShenandoahCollectorPolicy::process_references() { 926 return _heuristics->process_references(); 927 } 928 929 bool ShenandoahCollectorPolicy::unload_classes() { 930 return _heuristics->unload_classes(); 931 } 932 933 void ShenandoahCollectorPolicy::print_tracing_info(outputStream* out) { 934 out->cr(); 935 out->print_cr("GC STATISTICS:"); 936 out->print_cr(" \"gross\" pauses include time to safepoint. \"net\" pauses are times spent in GC."); 937 out->print_cr(" \"a\" is average time for each phase, look at levels to see if average makes sense."); 938 out->print_cr(" \"lvls\" are quantiles: 0%% (minimum), 25%%, 50%% (median), 75%%, 100%% (maximum)."); 939 out->cr(); 940 941 for (uint i = 0; i < _num_phases; i++) { 942 if (_timing_data[i]._secs.maximum() != 0) { 943 print_summary_sd(out, _phase_names[i], &(_timing_data[i]._secs)); 944 } 945 } 946 947 out->cr(); 948 out->print_cr("" SIZE_FORMAT " allocation failure and " SIZE_FORMAT " user requested GCs", _allocation_failure_gcs, _user_requested_gcs); 949 out->print_cr("" SIZE_FORMAT " successful and " SIZE_FORMAT " degenerated concurrent markings", _successful_cm, _degenerated_cm); 950 out->cr(); 951 } 952 953 void ShenandoahCollectorPolicy::print_summary_sd(outputStream* out, const char* str, const HdrSeq* seq) { 954 out->print_cr("%-27s = %8.2lf s (a = %8.0lf us) (n = "INT32_FORMAT_W(5)") (lvls, us = %8.0lf, %8.0lf, %8.0lf, %8.0lf, %8.0lf)", 955 str, 956 seq->sum(), 957 seq->avg() * 1000000.0, 958 seq->num(), 959 seq->percentile(0) * 1000000.0, 960 seq->percentile(25) * 1000000.0, 961 seq->percentile(50) * 1000000.0, 962 seq->percentile(75) * 1000000.0, 963 seq->maximum() * 1000000.0 964 ); 965 } 966 967 void ShenandoahCollectorPolicy::increase_cycle_counter() { 968 _cycle_counter++; 969 } 970 971 size_t ShenandoahCollectorPolicy::cycle_counter() const { 972 return _cycle_counter; 973 } 974 975 ShenandoahPhaseTimes* ShenandoahCollectorPolicy::phase_times() { 976 return _phase_times; 977 } 978 979 980 uint ShenandoahCollectorPolicy::calc_workers_for_java_threads(uint application_workers) { 981 return (uint)(ShenandoahGCWorkerPerJavaThread * application_workers); 982 } 983 984 uint ShenandoahCollectorPolicy::calc_workers_for_live_set(size_t live_data) { 985 return (uint)(live_data / HeapSizePerGCThread); 986 } 987 988 989 uint ShenandoahCollectorPolicy::calc_default_active_workers( 990 uint total_workers, 991 uint min_workers, 992 uint active_workers, 993 uint application_workers, 994 uint workers_by_java_threads, 995 uint workers_by_liveset) { 996 // If the user has turned off using a dynamic number of GC threads 997 // or the users has requested a specific number, set the active 998 // number of workers to all the workers. 999 uint new_active_workers = total_workers; 1000 uint prev_active_workers = active_workers; 1001 uint active_workers_by_JT = 0; 1002 uint active_workers_by_liveset = 0; 1003 1004 active_workers_by_JT = MAX2(workers_by_java_threads, min_workers); 1005 1006 // Choose a number of GC threads based on the live set. 1007 active_workers_by_liveset = 1008 MAX2((uint) 2U, workers_by_liveset); 1009 1010 uint max_active_workers = 1011 MAX2(active_workers_by_JT, active_workers_by_liveset); 1012 1013 new_active_workers = MIN2(max_active_workers, total_workers); 1014 1015 // Increase GC workers instantly but decrease them more 1016 // slowly. 1017 if (new_active_workers < prev_active_workers) { 1018 new_active_workers = 1019 MAX2(min_workers, (prev_active_workers + new_active_workers) / 2); 1020 } 1021 1022 if (UseNUMA) { 1023 uint numa_groups = (uint)os::numa_get_groups_num(); 1024 assert(numa_groups <= total_workers, "Not enough workers to cover all numa groups"); 1025 new_active_workers = MAX2(new_active_workers, numa_groups); 1026 } 1027 1028 // Check once more that the number of workers is within the limits. 1029 assert(min_workers <= total_workers, "Minimum workers not consistent with total workers"); 1030 assert(new_active_workers >= min_workers, "Minimum workers not observed"); 1031 assert(new_active_workers <= total_workers, "Total workers not observed"); 1032 1033 log_trace(gc, task)("ShenandoahCollectorPolicy::calc_default_active_workers() : " 1034 "active_workers(): " UINTX_FORMAT " new_active_workers: " UINTX_FORMAT " " 1035 "prev_active_workers: " UINTX_FORMAT "\n" 1036 " active_workers_by_JT: " UINTX_FORMAT " active_workers_by_liveset: " UINTX_FORMAT, 1037 (uintx)active_workers, (uintx)new_active_workers, (uintx)prev_active_workers, 1038 (uintx)active_workers_by_JT, (uintx)active_workers_by_liveset); 1039 assert(new_active_workers > 0, "Always need at least 1"); 1040 return new_active_workers; 1041 } 1042 1043 /** 1044 * Initial marking phase also update references of live objects from previous concurrent GC cycle, 1045 * so we take Java threads and live set into account. 1046 */ 1047 uint ShenandoahCollectorPolicy::calc_workers_for_init_marking(uint active_workers, 1048 uint application_workers) { 1049 1050 if (!UseDynamicNumberOfGCThreads || 1051 (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) { 1052 assert(ParallelGCThreads > 0, "Always need at least 1"); 1053 return ParallelGCThreads; 1054 } else { 1055 ShenandoahCollectorPolicy* policy = (ShenandoahCollectorPolicy*)ShenandoahHeap::heap()->collector_policy(); 1056 size_t live_data = policy->_heuristics->bytes_in_cset(); 1057 1058 return calc_default_active_workers(ParallelGCThreads, (ParallelGCThreads > 1) ? 2 : 1, 1059 active_workers, application_workers, 1060 calc_workers_for_java_threads(application_workers), 1061 calc_workers_for_live_set(live_data)); 1062 } 1063 } 1064 1065 uint ShenandoahCollectorPolicy::calc_workers_for_conc_marking(uint active_workers, 1066 uint application_workers) { 1067 1068 if (!UseDynamicNumberOfGCThreads || 1069 (!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) { 1070 assert(ConcGCThreads > 0, "Always need at least 1"); 1071 return ConcGCThreads; 1072 } else { 1073 return calc_default_active_workers(ConcGCThreads, 1074 (ConcGCThreads > 1 ? 2 : 1), active_workers, 1075 application_workers, calc_workers_for_java_threads(application_workers), 0); 1076 } 1077 } 1078 1079 uint ShenandoahCollectorPolicy::calc_workers_for_final_marking(uint active_workers, 1080 uint application_workers) { 1081 1082 if (!UseDynamicNumberOfGCThreads || 1083 (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) { 1084 assert(ParallelGCThreads > 0, "Always need at least 1"); 1085 return ParallelGCThreads; 1086 } else { 1087 return calc_default_active_workers(ParallelGCThreads, 1088 (ParallelGCThreads > 1 ? 2 : 1), active_workers, 1089 application_workers, calc_workers_for_java_threads(application_workers), 0); 1090 } 1091 } 1092 1093 // Calculate workers for concurrent evacuation (concurrent GC) 1094 uint ShenandoahCollectorPolicy::calc_workers_for_conc_evacuation(uint active_workers, 1095 uint application_workers) { 1096 if (!UseDynamicNumberOfGCThreads || 1097 (!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) { 1098 assert(ConcGCThreads > 0, "Always need at least 1"); 1099 return ConcGCThreads; 1100 } else { 1101 return calc_workers_for_evacuation(false, // not a full GC 1102 ConcGCThreads, active_workers, application_workers); 1103 } 1104 } 1105 1106 // Calculate workers for parallel evaculation (full GC) 1107 uint ShenandoahCollectorPolicy::calc_workers_for_parallel_evacuation(uint active_workers, 1108 uint application_workers) { 1109 if (!UseDynamicNumberOfGCThreads || 1110 (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) { 1111 assert(ParallelGCThreads > 0, "Always need at least 1"); 1112 return ParallelGCThreads; 1113 } else { 1114 return calc_workers_for_evacuation(true, // a full GC 1115 ParallelGCThreads, active_workers, application_workers); 1116 } 1117 } 1118 1119 1120 uint ShenandoahCollectorPolicy::calc_workers_for_evacuation(bool full_gc, 1121 uint total_workers, 1122 uint active_workers, 1123 uint application_workers) { 1124 1125 // Calculation based on live set 1126 size_t live_data = 0; 1127 ShenandoahHeap* heap = ShenandoahHeap::heap(); 1128 if (full_gc) { 1129 ShenandoahHeapRegionSet* regions = heap->regions(); 1130 for (size_t index = 0; index < regions->active_regions(); index ++) { 1131 live_data += regions->get_fast(index)->get_live_data_bytes(); 1132 } 1133 } else { 1134 ShenandoahCollectorPolicy* policy = (ShenandoahCollectorPolicy*)heap->collector_policy(); 1135 live_data = policy->_heuristics->bytes_in_cset(); 1136 } 1137 1138 uint active_workers_by_liveset = calc_workers_for_live_set(live_data); 1139 return calc_default_active_workers(total_workers, 1140 (total_workers > 1 ? 2 : 1), active_workers, 1141 application_workers, 0, active_workers_by_liveset); 1142 } 1143 1144 bool ShenandoahCollectorPolicy::should_start_partial_gc() { 1145 return _heuristics->should_start_partial_gc(); 1146 }