--- /dev/null 2015-11-03 09:29:33.822158357 +0100 +++ new/src/share/vm/gc/g1/g1IHOPControl.hpp 2015-11-06 11:34:08.420393384 +0100 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_G1_G1IHOPCONTROL_HPP +#define SHARE_VM_GC_G1_G1IHOPCONTROL_HPP + +#include "memory/allocation.hpp" +#include "utilities/numberSeq.hpp" + +class G1Predictions; + +// Manages the decision about the threshold when concurrent marking should start. +class G1IHOPControl : public CHeapObj { + protected: + double _ihop_percent; + size_t _target_occupancy; + + // Initialize an instance with the initial IHOP value in percent and the target + // occupancy. The target occupancy is the number of bytes when marking should + // be finished and reclaim started. + G1IHOPControl(double initial_ihop_percent, size_t target_occupancy); + public: + virtual ~G1IHOPControl() { } + + // Get the current marking threshold in bytes. + virtual size_t get_conc_mark_start_threshold() = 0; + + // Update information about recent time during which allocations happened, + // how many allocations happened and an additional safety buffer. + virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) = 0; + // Update the time from the end of initial mark to the first mixed gc. + virtual void update_time_to_mixed(double marking_length_s) = 0; + + virtual void print() = 0; +}; + +class G1StaticIHOPControl : public G1IHOPControl { + double _last_allocation_time_s; + size_t _last_allocated_bytes; + double _last_marking_length_s; + public: + G1StaticIHOPControl(double ihop_percent, size_t target_occupancy); + + size_t get_conc_mark_start_threshold() { return (size_t) (_ihop_percent * _target_occupancy / 100.0); } + + virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) { + assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s); + _last_allocation_time_s = allocation_time_s; + _last_allocated_bytes = allocated_bytes; + } + + virtual void update_time_to_mixed(double marking_length_s) { + assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s); + _last_marking_length_s = marking_length_s; + } + + virtual void print(); +#ifndef PRODUCT + static void test(); +#endif +}; + +#endif // SHARE_VM_GC_G1_G1IHOPCONTROL_HPP