src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp
src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp
Print this page
*** 22,31 ****
--- 22,32 ----
*
*/
#include "precompiled.hpp"
#include "gc_implementation/parallelScavenge/generationSizer.hpp"
+ #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
#include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
#include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
#include "gc_implementation/shared/gcPolicyCounters.hpp"
#include "gc_interface/gcCause.hpp"
*** 76,85 ****
--- 77,118 ----
_major_timer.start();
_old_gen_policy_is_ready = false;
}
+ size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) {
+ // We want to calculate how much free memory there can be based on the
+ // amount of live data currently in the old gen. Using the formula:
+ // ratio * (free + live) = free
+ // Some equation solving later we get:
+ // free = (live * ratio) / (1 - ratio)
+
+ const double ratio = ratio_as_percentage / 100.0;
+ const double ratio_inverse = 1.0 - ratio;
+ const double tmp = live * ratio;
+ size_t free = (size_t)(tmp / ratio_inverse);
+
+ return free;
+ }
+
+ size_t PSAdaptiveSizePolicy::calculated_old_free_size_in_bytes() const {
+ size_t free_size = (size_t)(_promo_size + avg_promoted()->padded_average());
+ size_t live = ParallelScavengeHeap::heap()->old_gen()->used_in_bytes();
+
+ if (MinHeapFreeRatio != 0) {
+ size_t min_free = calculate_free_based_on_live(live, MinHeapFreeRatio);
+ free_size = MAX2(free_size, min_free);
+ }
+
+ if (MaxHeapFreeRatio != 100) {
+ size_t max_free = calculate_free_based_on_live(live, MaxHeapFreeRatio);
+ free_size = MIN2(max_free, free_size);
+ }
+
+ return free_size;
+ }
+
void PSAdaptiveSizePolicy::major_collection_begin() {
// Update the interval time
_major_timer.stop();
// Save most recent collection time
_latest_major_mutator_interval_seconds = _major_timer.seconds();
*** 1105,1109 ****
--- 1138,1157 ----
return AdaptiveSizePolicy::print_adaptive_size_policy_on(
st,
PSScavenge::tenuring_threshold());
}
+
+ #ifndef PRODUCT
+
+ void TestOldFreeSpaceCalculation_test() {
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 20) == 25, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 50) == 100, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 60) == 150, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(100, 75) == 300, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 20) == 100, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 50) == 400, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 60) == 600, "Calculation of free memory failed");
+ assert(PSAdaptiveSizePolicy::calculate_free_based_on_live(400, 75) == 1200, "Calculation of free memory failed");
+ }
+
+ #endif /* !PRODUCT */
src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File