< prev index next >
src/share/vm/gc/g1/g1IHOPControl.cpp
Print this page
rev 11935 : 8159818: Convert IHOP_test to GTest
Reviewed-by: duke
*** 79,129 ****
G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent) :
G1IHOPControl(ihop_percent),
_last_marking_length_s(0.0) {
}
- #ifndef PRODUCT
- static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
- for (int i = 0; i < 100; i++) {
- ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
- ctrl->update_marking_length(mark_time);
- }
- }
-
- void G1StaticIHOPControl::test() {
- size_t const initial_ihop = 45;
-
- G1StaticIHOPControl ctrl(initial_ihop);
- ctrl.update_target_occupancy(100);
-
- size_t threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- ctrl.update_allocation_info(100.0, 100, 100);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- ctrl.update_marking_length(1000.0);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- // Whatever we pass, the IHOP value must stay the same.
- test_update(&ctrl, 2, 10, 10, 3);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
-
- test_update(&ctrl, 12, 10, 10, 3);
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_ihop,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
- }
- #endif
-
G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
G1Predictions const* predictor,
size_t heap_reserve_percent,
size_t heap_waste_percent) :
G1IHOPControl(ihop_percent),
--- 79,88 ----
*** 222,302 ****
_last_unrestrained_young_size,
_predictor->get_new_prediction(&_allocation_rate_s),
_predictor->get_new_prediction(&_marking_times_s),
have_enough_data_for_prediction());
}
-
- #ifndef PRODUCT
- void G1AdaptiveIHOPControl::test() {
- size_t const initial_threshold = 45;
- size_t const young_size = 10;
- size_t const target_size = 100;
-
- // The final IHOP value is always
- // target_size - (young_size + alloc_amount/alloc_time * marking_time)
-
- G1Predictions pred(0.95);
- G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
- ctrl.update_target_occupancy(target_size);
-
- // First "load".
- size_t const alloc_time1 = 2;
- size_t const alloc_amount1 = 10;
- size_t const marking_time1 = 2;
- size_t const settled_ihop1 = target_size - (young_size + alloc_amount1/alloc_time1 * marking_time1);
-
- size_t threshold;
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_threshold,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
- for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
- ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
- ctrl.update_marking_length(marking_time1);
- // Not enough data yet.
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == initial_threshold,
- "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
- }
-
- test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
-
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold == settled_ihop1,
- "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
-
- // Second "load". A bit higher allocation rate.
- size_t const alloc_time2 = 2;
- size_t const alloc_amount2 = 30;
- size_t const marking_time2 = 2;
- size_t const settled_ihop2 = target_size - (young_size + alloc_amount2/alloc_time2 * marking_time2);
-
- test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
-
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold < settled_ihop1,
- "Expected IHOP threshold to settle at a value lower than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
-
- // Third "load". Very high (impossible) allocation rate.
- size_t const alloc_time3 = 1;
- size_t const alloc_amount3 = 50;
- size_t const marking_time3 = 2;
- size_t const settled_ihop3 = 0;
-
- test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
- threshold = ctrl.get_conc_mark_start_threshold();
-
- assert(threshold == settled_ihop3,
- "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
-
- // And back to some arbitrary value.
- test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
-
- threshold = ctrl.get_conc_mark_start_threshold();
- assert(threshold > settled_ihop3,
- "Expected IHOP threshold to settle at value larger than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
- }
-
- void IHOP_test() {
- G1StaticIHOPControl::test();
- G1AdaptiveIHOPControl::test();
- }
- #endif
--- 181,185 ----
< prev index next >