comparison src/share/vm/memory/collectorPolicy.cpp @ 2368:dde920245681

6896099: Integrate CMS heap ergo with default heap sizing ergo 6627787: CMS: JVM refuses to start up with -Xms16m -Xmx16m 7000125: CMS: Anti-monotone young gen sizing with respect to maximum whole heap size specification 7027529: CMS: retire CMSUseOldDefaults flag Summary: Simplify CMS heap sizing code, relying on ergonomic initial sizing consistent with other collectors for the most part, controlling only young gen sizing to rein in pause times. Make CMS young gen sizing default statically cpu-dependant. Remove inconsistencies wrt generation sizing and policy code, allowing for the fixing for 6627787 and 7000125. For 7027529, retire the flag CMSUseOldDefaults which had been introduced as a bridge from JDK 5 to JDK 6 a number of years ago. Reviewed-by: brutisso, poonam
author ysr
date Wed, 16 Mar 2011 10:37:08 -0700
parents 6cd6d394f280
children a1d5f532838d
comparison
equal deleted inserted replaced
2367:1abd292f8c38 2368:dde920245681
1 /* 1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
291 // generations sizes. 291 // generations sizes.
292 292
293 // Determine maximum size of gen0 293 // Determine maximum size of gen0
294 294
295 size_t max_new_size = 0; 295 size_t max_new_size = 0;
296 if (FLAG_IS_CMDLINE(MaxNewSize)) { 296 if (FLAG_IS_CMDLINE(MaxNewSize) || FLAG_IS_ERGO(MaxNewSize)) {
297 if (MaxNewSize < min_alignment()) { 297 if (MaxNewSize < min_alignment()) {
298 max_new_size = min_alignment(); 298 max_new_size = min_alignment();
299 } else if (MaxNewSize >= max_heap_byte_size()) { 299 }
300 if (MaxNewSize >= max_heap_byte_size()) {
300 max_new_size = align_size_down(max_heap_byte_size() - min_alignment(), 301 max_new_size = align_size_down(max_heap_byte_size() - min_alignment(),
301 min_alignment()); 302 min_alignment());
302 warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or " 303 warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or "
303 "greater than the entire heap (" SIZE_FORMAT "k). A " 304 "greater than the entire heap (" SIZE_FORMAT "k). A "
304 "new generation size of " SIZE_FORMAT "k will be used.", 305 "new generation size of " SIZE_FORMAT "k will be used.",
331 max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize); 332 max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize);
332 } 333 }
333 assert(max_new_size > 0, "All paths should set max_new_size"); 334 assert(max_new_size > 0, "All paths should set max_new_size");
334 335
335 // Given the maximum gen0 size, determine the initial and 336 // Given the maximum gen0 size, determine the initial and
336 // minimum sizes. 337 // minimum gen0 sizes.
337 338
338 if (max_heap_byte_size() == min_heap_byte_size()) { 339 if (max_heap_byte_size() == min_heap_byte_size()) {
339 // The maximum and minimum heap sizes are the same so 340 // The maximum and minimum heap sizes are the same so
340 // the generations minimum and initial must be the 341 // the generations minimum and initial must be the
341 // same as its maximum. 342 // same as its maximum.
394 MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size)); 395 MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size));
395 set_min_gen0_size(MIN2(_min_gen0_size, _initial_gen0_size)); 396 set_min_gen0_size(MIN2(_min_gen0_size, _initial_gen0_size));
396 } 397 }
397 398
398 if (PrintGCDetails && Verbose) { 399 if (PrintGCDetails && Verbose) {
399 gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT " Initial gen0 " 400 gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT " Initial gen0 "
400 SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, 401 SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT,
401 min_gen0_size(), initial_gen0_size(), max_gen0_size()); 402 min_gen0_size(), initial_gen0_size(), max_gen0_size());
402 } 403 }
403 } 404 }
404 405
446 GenCollectorPolicy::initialize_size_info(); 447 GenCollectorPolicy::initialize_size_info();
447 448
448 // At this point the minimum, initial and maximum sizes 449 // At this point the minimum, initial and maximum sizes
449 // of the overall heap and of gen0 have been determined. 450 // of the overall heap and of gen0 have been determined.
450 // The maximum gen1 size can be determined from the maximum gen0 451 // The maximum gen1 size can be determined from the maximum gen0
451 // and maximum heap size since not explicit flags exits 452 // and maximum heap size since no explicit flags exits
452 // for setting the gen1 maximum. 453 // for setting the gen1 maximum.
453 _max_gen1_size = max_heap_byte_size() - _max_gen0_size; 454 _max_gen1_size = max_heap_byte_size() - _max_gen0_size;
454 _max_gen1_size = 455 _max_gen1_size =
455 MAX2((uintx)align_size_down(_max_gen1_size, min_alignment()), 456 MAX2((uintx)align_size_down(_max_gen1_size, min_alignment()),
456 min_alignment()); 457 min_alignment());
492 if ((OldSize > _max_gen1_size)) { 493 if ((OldSize > _max_gen1_size)) {
493 warning("Inconsistency between maximum heap size and maximum " 494 warning("Inconsistency between maximum heap size and maximum "
494 "generation sizes: using maximum heap = " SIZE_FORMAT 495 "generation sizes: using maximum heap = " SIZE_FORMAT
495 " -XX:OldSize flag is being ignored", 496 " -XX:OldSize flag is being ignored",
496 max_heap_byte_size()); 497 max_heap_byte_size());
497 } 498 }
498 // If there is an inconsistency between the OldSize and the minimum and/or 499 // If there is an inconsistency between the OldSize and the minimum and/or
499 // initial size of gen0, since OldSize was explicitly set, OldSize wins. 500 // initial size of gen0, since OldSize was explicitly set, OldSize wins.
500 if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size, 501 if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size,
501 min_heap_byte_size(), OldSize)) { 502 min_heap_byte_size(), OldSize)) {
502 if (PrintGCDetails && Verbose) { 503 if (PrintGCDetails && Verbose) {
503 gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT " Initial gen0 " 504 gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT " Initial gen0 "
504 SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, 505 SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT,
505 min_gen0_size(), initial_gen0_size(), max_gen0_size()); 506 min_gen0_size(), initial_gen0_size(), max_gen0_size());
506 } 507 }
507 } 508 }
508 // Initial size 509 // Initial size
509 if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size, 510 if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size,
510 initial_heap_byte_size(), OldSize)) { 511 initial_heap_byte_size(), OldSize)) {
511 if (PrintGCDetails && Verbose) { 512 if (PrintGCDetails && Verbose) {
512 gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT " Initial gen0 " 513 gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT " Initial gen0 "
513 SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, 514 SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT,
514 min_gen0_size(), initial_gen0_size(), max_gen0_size()); 515 min_gen0_size(), initial_gen0_size(), max_gen0_size());
515 } 516 }
516 } 517 }
517 } 518 }