use of org.openjdk.jol.info.GraphLayout in project ignite by apache.
the class FileStoreHeapUtilizationJolBenchmark method testGrid.
/**
*/
private Map<TestResultParameterInfo, Comparable> testGrid() {
String name = UUID.randomUUID().toString().substring(0, 8);
Ignite ignite = Ignition.start(getConfiguration(name));
ignite.cluster().active(true);
long start = System.currentTimeMillis();
IgniteCache<Object, Object> cache = ignite.getOrCreateCache(CACHE_NAME);
for (int i = 0; i < 100; i++) cache.put(i, new byte[512]);
for (int i = 50; i < 100; i++) cache.remove(i);
for (int i = 50; i < 150; i++) cache.put(i, new byte[512]);
long time = System.currentTimeMillis() - start;
GraphLayout layout = GraphLayout.parseInstance(ignite);
ignite.cluster().active(false);
Ignition.stop(name, true);
return new HashMap<TestResultParameterInfo, Comparable>() {
{
put(HEAP_USAGE_PARAM, layout.totalSize());
put(CACHE_WORK_TIME_PARAM, time);
}
};
}
use of org.openjdk.jol.info.GraphLayout in project ignite by apache.
the class GridAffinityAssignmentJolBenchmark method measureHistory0.
/**
* @param parts Parts.
* @param nodeCnt Node count.
* @param disableOptimization Disable optimization.
*/
private static long measureHistory0(int parts, int nodeCnt, boolean disableOptimization, int backups) throws Exception {
System.gc();
setOptimization(disableOptimization);
RendezvousAffinityFunction aff = new RendezvousAffinityFunction(true, parts);
List<ClusterNode> nodes = new ArrayList<>(nodeCnt);
nodes.add(node(0));
Map<AffinityTopologyVersion, HistoryAffinityAssignment> affCache = new ConcurrentSkipListMap<>();
List<List<ClusterNode>> prevAssignment = new ArrayList<>();
prevAssignment = aff.assignPartitions(context(new ArrayList<>(nodes), prevAssignment, 1));
for (int i = 1; i < nodeCnt; i++) {
ClusterNode newNode = node(i);
nodes.add(newNode);
List<List<ClusterNode>> idealAssignment = aff.assignPartitions(context(new ArrayList<>(nodes), prevAssignment, backups));
List<List<ClusterNode>> lateAssignmemnt = new ArrayList<>(parts);
for (int j = 0; j < idealAssignment.size(); j++) {
List<ClusterNode> ideal0 = idealAssignment.get(j);
List<ClusterNode> prev = prevAssignment.get(j);
ClusterNode curPrimary = prev.get(0);
if (!curPrimary.equals(ideal0.get(0))) {
List<ClusterNode> cpy = new ArrayList<>(ideal0);
cpy.remove(curPrimary);
cpy.add(0, curPrimary);
lateAssignmemnt.add(cpy);
} else
lateAssignmemnt.add(ideal0);
}
AffinityTopologyVersion topVer = new AffinityTopologyVersion(i + 1, 0);
GridAffinityAssignmentV2 a = new GridAffinityAssignmentV2(topVer, lateAssignmemnt, idealAssignment);
HistoryAffinityAssignment h = new HistoryAffinityAssignmentImpl(a, backups);
if (!lateAssignmemnt.equals(h.assignment()))
throw new RuntimeException();
if (!idealAssignment.equals(h.idealAssignment()))
throw new RuntimeException();
affCache.put(topVer, h);
AffinityTopologyVersion topVer0 = new AffinityTopologyVersion(i + 1, 1);
List<List<ClusterNode>> assignment = new ArrayList<>(parts);
for (int j = 0; j < idealAssignment.size(); j++) {
List<ClusterNode> clusterNodes = idealAssignment.get(j);
assignment.add(clusterNodes);
}
GridAffinityAssignmentV2 a0 = new GridAffinityAssignmentV2(topVer0, assignment, idealAssignment);
HistoryAffinityAssignment h0 = new HistoryAffinityAssignmentImpl(a0, backups);
if (!assignment.equals(h0.assignment()))
throw new RuntimeException();
if (!idealAssignment.equals(h0.idealAssignment()))
throw new RuntimeException();
affCache.put(topVer0, h0);
prevAssignment = idealAssignment;
}
System.gc();
GraphLayout l = GraphLayout.parseInstance(affCache);
// Exclude nodes from estimation.
GraphLayout l2 = GraphLayout.parseInstance(nodes.toArray(new Object[nodes.size()]));
GraphLayout l3 = l.subtract(l2);
System.out.println("Heap usage [optimized=" + !disableOptimization + ", parts=" + parts + ", nodeCnt=" + nodeCnt + ", backups=" + backups + ", " + l3.toFootprint() + ']');
return l3.totalSize();
}
use of org.openjdk.jol.info.GraphLayout in project antlr4 by tunnelvisionlabs.
the class TimeLexerSpeed method load_legacy_java_ascii_file.
@SuppressWarnings("deprecation")
public void load_legacy_java_ascii_file(String resourceName, int n) throws Exception {
URL sampleJavaFile = TimeLexerSpeed.class.getClassLoader().getResource(resourceName);
if (sampleJavaFile == null) {
System.err.println("Can't run load_legacy_java_ascii_file from jar (or can't find " + resourceName + ")");
// cannot find resource
return;
}
if (!new File(sampleJavaFile.getFile()).exists()) {
System.err.println("Can't run load_legacy_java_ascii_file from jar (or can't find " + resourceName + ")");
return;
}
long start = System.nanoTime();
// keep refs around so we can average memory
CharStream[] input = new CharStream[n];
for (int i = 0; i < n; i++) {
input[i] = new org.antlr.v4.runtime.ANTLRFileStream(sampleJavaFile.getFile());
}
long stop = System.nanoTime();
long tus = (stop - start) / 1000;
int size = input[0].size();
String currentMethodName = new Exception().getStackTrace()[0].getMethodName();
GraphLayout olayout = GraphLayout.parseInstance((Object) input[0]);
long streamSize = olayout.totalSize();
streamFootprints.add(basename(resourceName) + " (" + size + " char): " + olayout.toFootprint());
if (output)
System.out.printf("%27s average time %5dus size %6db over %4d loads of %5d symbols from %s\n", currentMethodName, tus / n, streamSize, n, size, basename(resourceName));
}
use of org.openjdk.jol.info.GraphLayout in project antlr4 by antlr.
the class TimeLexerSpeed method load_legacy_java_ascii_file.
public void load_legacy_java_ascii_file(String resourceName, int n) throws Exception {
URL sampleJavaFile = TimeLexerSpeed.class.getClassLoader().getResource(resourceName);
if (sampleJavaFile == null) {
System.err.println("Can't run load_legacy_java_ascii_file from jar (or can't find " + resourceName + ")");
// cannot find resource
return;
}
if (!new File(sampleJavaFile.getFile()).exists()) {
System.err.println("Can't run load_legacy_java_ascii_file from jar (or can't find " + resourceName + ")");
return;
}
long start = System.nanoTime();
// keep refs around so we can average memory
CharStream[] input = new CharStream[n];
for (int i = 0; i < n; i++) {
input[i] = new ANTLRFileStream(sampleJavaFile.getFile());
}
long stop = System.nanoTime();
long tus = (stop - start) / 1000;
int size = input[0].size();
String currentMethodName = new Exception().getStackTrace()[0].getMethodName();
GraphLayout olayout = GraphLayout.parseInstance((Object) input[0]);
long streamSize = olayout.totalSize();
streamFootprints.add(basename(resourceName) + " (" + size + " char): " + olayout.toFootprint());
if (output)
System.out.printf("%27s average time %5dus size %6db over %4d loads of %5d symbols from %s\n", currentMethodName, tus / n, streamSize, n, size, basename(resourceName));
}
Aggregations