Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bc0f068
Heap/GC cleanups.
peter-hofer Jul 14, 2021
defe463
Rename HeapPolicy to HeapParameters.
peter-hofer Jul 14, 2021
f9eedbe
Use survivor spaces also during full collections.
peter-hofer Jul 15, 2021
38e4c69
Move promoteObject() to GCImpl from HeapImpl.
peter-hofer Jul 15, 2021
e886010
Use survivor spaces for chunks with pinned objects, too.
peter-hofer Jul 15, 2021
066695b
Abstract collection policy concerns.
peter-hofer Jul 16, 2021
2028eea
Introduce an adaptive collection policy.
peter-hofer Jul 21, 2021
e23928f
Overflow survivor spaces into old generation.
peter-hofer Jul 28, 2021
1792bba
Release chunks from the free list when they exceed the capacity of ed…
peter-hofer Jul 29, 2021
d94a2db
Use chunk bytes for computing the survivors capacity.
peter-hofer Jul 29, 2021
92bb451
Update remembered set correctly when a reference object is tenured wh…
peter-hofer Aug 2, 2021
bb9424e
Properly support heap without survivor spaces in adaptive policy and …
peter-hofer Aug 10, 2021
591d45e
Do not copy or age young objects in a full GC immediately following a…
peter-hofer Aug 11, 2021
47455c8
Address review comments.
peter-hofer Aug 13, 2021
8d96b79
Select policy by short name and further refactorings.
peter-hofer Aug 16, 2021
d68b841
Reduce size increment steps and disable startup supplements for small…
peter-hofer Aug 17, 2021
0ffc561
Add least-square estimators for throughput adjustments.
peter-hofer Aug 18, 2021
b966869
Use reciprocal b+a/x least-squares fit to estimate limit on throughput.
peter-hofer Aug 20, 2021
a9124fd
Limit reserved aligned chunks by their typical fraction of the young …
peter-hofer Aug 25, 2021
4499d7e
Collect completely after multiple consecutive incremental collections.
peter-hofer Aug 31, 2021
c53b788
Extract abstract policy base class.
peter-hofer Aug 27, 2021
99daa96
Port HotSpot SerialGC policy.
peter-hofer Aug 27, 2021
10eb8d5
Always collect incrementally first and retain chunks to reduce memory…
peter-hofer Sep 2, 2021
6dc5ec2
Fix race of eden allocation size updates with potential GC and result…
peter-hofer Sep 8, 2021
d0953b0
Address review comments.
peter-hofer Sep 8, 2021
5e1e23c
Reintroduce HeapPolicy, HeapPolicyOptions as proxies for legacy code.
peter-hofer Sep 9, 2021
6cf22c5
Adjust MaxSurvivorSpaces option depending on policy.
peter-hofer Sep 10, 2021
db1b88c
Change default policy back to BySpaceAndTime for now.
peter-hofer Sep 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
* Copyright (c) 2021, 2021, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package com.oracle.svm.core.genscavenge;

import org.graalvm.word.UnsignedWord;

import com.oracle.svm.core.util.UnsignedUtils;

/**
* A weighted average maintains a running, weighted average of some floating-point value.
*
* The average is adaptive in that we smooth it for the initial samples; we don't use the weight
* until we have enough samples for it to be meaningful.
*
* This serves as our best estimate of a future unknown.
*/
class AdaptiveWeightedAverage {
static final int OLD_THRESHOLD = 100;

private final int weight;

private double average;
private long sampleCount;
private boolean isOld;

AdaptiveWeightedAverage(int weight) {
this(weight, 0);
}

AdaptiveWeightedAverage(int weight, double avg) {
this.weight = weight;
this.average = avg;
}

public double getAverage() {
return average;
}

public void sample(double value) {
sampleCount++;
if (!isOld && sampleCount > OLD_THRESHOLD) {
isOld = true;
}
average = computeAdaptiveAverage(value, average);
}

public final void sample(UnsignedWord value) {
sample(UnsignedUtils.toDouble(value));
}

protected double computeAdaptiveAverage(double sample, double avg) {
/*
* We smoothen the samples by not using weight directly until we've had enough data to make
* it meaningful. We'd like the first weight used to be 1, the second to be 1/2, etc until
* we have OLD_THRESHOLD/weight samples.
*/
long countWeight = 0;
if (!isOld) { // avoid division by zero if the counter wraps
countWeight = OLD_THRESHOLD / sampleCount;
}
long adaptiveWeight = Math.max(weight, countWeight);
return expAvg(avg, sample, adaptiveWeight);
}

private static double expAvg(double avg, double sample, long adaptiveWeight) {
assert adaptiveWeight <= 100 : "weight must be a percentage";
return (100.0 - adaptiveWeight) * avg / 100.0 + adaptiveWeight * sample / 100.0;
}
}

/**
* A weighted average that includes a deviation from the average, some multiple of which is added to
* the average.
*
* This serves as our best estimate of an upper bound on a future unknown.
*/
class AdaptivePaddedAverage extends AdaptiveWeightedAverage {
private final int padding;
private final boolean noZeroDeviations;

private double paddedAverage;
private double deviation;

AdaptivePaddedAverage(int weight, int padding) {
this(weight, padding, false);
}

/**
* @param noZeroDeviations do not update deviations when a sample is zero. The average is
* allowed to change. This is to prevent zero samples from drastically changing the
* padded average.
*/
AdaptivePaddedAverage(int weight, int padding, boolean noZeroDeviations) {
super(weight);
this.padding = padding;
this.noZeroDeviations = noZeroDeviations;
}

@Override
public void sample(double value) {
super.sample(value);
double average = super.getAverage();
if (value != 0 || !noZeroDeviations) {
deviation = computeAdaptiveAverage(Math.abs(value - average), deviation);
}
paddedAverage = average + padding * deviation;
}

public double getPaddedAverage() {
return paddedAverage;
}

public double getDeviation() {
return deviation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static AlignedHeader getEnclosingChunk(Object obj) {
}

public static AlignedHeader getEnclosingChunkFromObjectPointer(Pointer ptr) {
return (AlignedHeader) PointerUtils.roundDown(ptr, HeapPolicy.getAlignedHeapChunkAlignment());
return (AlignedHeader) PointerUtils.roundDown(ptr, HeapParameters.getAlignedHeapChunkAlignment());
}

/** Return the offset of an object within the objects part of a chunk. */
Expand Down
Loading