11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
26 #define SHARE_VM_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
27
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/gcCause.hpp"
30 #include "gc/shared/gcUtil.hpp"
31 #include "memory/allocation.hpp"
32 #include "memory/universe.hpp"
33
34 // This class keeps statistical information and computes the
35 // size of the heap.
36
37 // Forward decls
38 class elapsedTimer;
39 class CollectorPolicy;
40
41 class AdaptiveSizePolicy : public CHeapObj<mtGC> {
42 friend class GCAdaptivePolicyCounters;
43 friend class PSGCAdaptivePolicyCounters;
44 friend class CMSGCAdaptivePolicyCounters;
45 protected:
46
47 enum GCPolicyKind {
48 _gc_adaptive_size_policy,
49 _gc_ps_adaptive_size_policy,
50 _gc_cms_adaptive_size_policy
483 size_t eden_live,
484 size_t max_old_gen_size,
485 size_t max_eden_size,
486 bool is_full_gc,
487 GCCause::Cause gc_cause,
488 CollectorPolicy* collector_policy);
489
490 static bool should_update_promo_stats(GCCause::Cause cause) {
491 return ((GCCause::is_user_requested_gc(cause) &&
492 UseAdaptiveSizePolicyWithSystemGC) ||
493 GCCause::is_tenured_allocation_failure_gc(cause));
494 }
495
496 static bool should_update_eden_stats(GCCause::Cause cause) {
497 return ((GCCause::is_user_requested_gc(cause) &&
498 UseAdaptiveSizePolicyWithSystemGC) ||
499 GCCause::is_allocation_failure_gc(cause));
500 }
501
502 // Printing support
503 virtual bool print_adaptive_size_policy_on(outputStream* st) const;
504 bool print_adaptive_size_policy_on(outputStream* st,
505 uint tenuring_threshold) const;
506 };
507
508 // Class that can be used to print information about the
509 // adaptive size policy at intervals specified by
510 // AdaptiveSizePolicyOutputInterval. Only print information
511 // if an adaptive size policy is in use.
512 class AdaptiveSizePolicyOutput : StackObj {
513 AdaptiveSizePolicy* _size_policy;
514 bool _do_print;
515 bool print_test(uint count) {
516 // A count of zero is a special value that indicates that the
517 // interval test should be ignored. An interval is of zero is
518 // a special value that indicates that the interval test should
519 // always fail (never do the print based on the interval test).
520 return PrintGCDetails &&
521 UseAdaptiveSizePolicy &&
522 UseParallelGC &&
523 (AdaptiveSizePolicyOutputInterval > 0) &&
524 ((count == 0) ||
525 ((count % AdaptiveSizePolicyOutputInterval) == 0));
526 }
527 public:
528 // The special value of a zero count can be used to ignore
529 // the count test.
530 AdaptiveSizePolicyOutput(uint count) {
531 if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) {
532 CollectedHeap* heap = Universe::heap();
533 _size_policy = heap->size_policy();
534 _do_print = print_test(count);
535 } else {
536 _size_policy = NULL;
537 _do_print = false;
538 }
539 }
540 AdaptiveSizePolicyOutput(AdaptiveSizePolicy* size_policy,
541 uint count) :
542 _size_policy(size_policy) {
543 if (UseAdaptiveSizePolicy && (AdaptiveSizePolicyOutputInterval > 0)) {
544 _do_print = print_test(count);
545 } else {
546 _do_print = false;
547 }
548 }
549 ~AdaptiveSizePolicyOutput() {
550 if (_do_print) {
551 assert(UseAdaptiveSizePolicy, "Should not be in use");
552 _size_policy->print_adaptive_size_policy_on(gclog_or_tty);
553 }
554 }
555 };
556
557 #endif // SHARE_VM_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
26 #define SHARE_VM_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
27
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/gcCause.hpp"
30 #include "gc/shared/gcUtil.hpp"
31 #include "logging/log.hpp"
32 #include "memory/allocation.hpp"
33 #include "memory/universe.hpp"
34
35 // This class keeps statistical information and computes the
36 // size of the heap.
37
38 // Forward decls
39 class elapsedTimer;
40 class CollectorPolicy;
41
42 class AdaptiveSizePolicy : public CHeapObj<mtGC> {
43 friend class GCAdaptivePolicyCounters;
44 friend class PSGCAdaptivePolicyCounters;
45 friend class CMSGCAdaptivePolicyCounters;
46 protected:
47
48 enum GCPolicyKind {
49 _gc_adaptive_size_policy,
50 _gc_ps_adaptive_size_policy,
51 _gc_cms_adaptive_size_policy
484 size_t eden_live,
485 size_t max_old_gen_size,
486 size_t max_eden_size,
487 bool is_full_gc,
488 GCCause::Cause gc_cause,
489 CollectorPolicy* collector_policy);
490
491 static bool should_update_promo_stats(GCCause::Cause cause) {
492 return ((GCCause::is_user_requested_gc(cause) &&
493 UseAdaptiveSizePolicyWithSystemGC) ||
494 GCCause::is_tenured_allocation_failure_gc(cause));
495 }
496
497 static bool should_update_eden_stats(GCCause::Cause cause) {
498 return ((GCCause::is_user_requested_gc(cause) &&
499 UseAdaptiveSizePolicyWithSystemGC) ||
500 GCCause::is_allocation_failure_gc(cause));
501 }
502
503 // Printing support
504 virtual bool print() const;
505 void print_tenuring_threshold(uint new_tenuring_threshold) const;
506 };
507
508 // Class that can be used to print information about the
509 // adaptive size policy at intervals specified by
510 // AdaptiveSizePolicyOutputInterval. Only print information
511 // if an adaptive size policy is in use.
512 class AdaptiveSizePolicyOutput : StackObj {
513 static bool enabled() {
514 return UseParallelGC &&
515 UseAdaptiveSizePolicy &&
516 Log<LOG_TAGS(gc, ergo)>::is_debug();
517 }
518 public:
519 static void print() {
520 if (enabled()) {
521 Universe::heap()->size_policy()->print();
522 }
523 }
524
525 static void print(AdaptiveSizePolicy* size_policy, uint count) {
526 bool do_print =
527 enabled() &&
528 (AdaptiveSizePolicyOutputInterval > 0) &&
529 (count % AdaptiveSizePolicyOutputInterval) == 0;
530
531 if (do_print) {
532 size_policy->print();
533 }
534 }
535 };
536
537 #endif // SHARE_VM_GC_SHARED_ADAPTIVESIZEPOLICY_HPP
|