Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace printStackTrace() to using java.util.logging #49

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ final BaseType get(int at) {
BaseType[] elements = (BaseType []) fan_out_node[at / max_length];
return elements[at % max_length];
}

final void set(int at, BaseType value) {
if ((at < 0) || (at >= length)) {
Exception x = new ArrayIndexOutOfBoundsException(at);
Expand Down Expand Up @@ -189,7 +189,6 @@ public static void main(String args[]) {
}
} catch (Exception x) {
Trace.debug("caught exception during first batch");
x.printStackTrace();
}

try {
Expand All @@ -204,7 +203,7 @@ public static void main(String args[]) {
}
} catch (Exception x) {
Trace.debug("caught exception during second batch");
x.printStackTrace();
Util.printException(x);
}

try {
Expand All @@ -219,7 +218,7 @@ public static void main(String args[]) {
}
} catch (Exception x) {
Trace.debug("caught exception during third batch");
x.printStackTrace();
Util.printException(x);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ final long get(int at) {
long[] elements = (long []) fan_out_node[at / max_length];
return elements[at % max_length];
}

final void set(int at, long value) {
if ((at < 0) || (at >= length)) {
Exception x = new ArrayIndexOutOfBoundsException(at);
Expand Down Expand Up @@ -195,7 +195,7 @@ public static void main(String args[]) {
}
} catch (Exception x) {
Trace.debug("caught exception during first batch");
x.printStackTrace();
Util.printException(x);
}

try {
Expand All @@ -210,7 +210,7 @@ public static void main(String args[]) {
}
} catch (Exception x) {
Trace.debug("caught exception during second batch");
x.printStackTrace();
Util.printException(x);
}

try {
Expand All @@ -225,7 +225,7 @@ public static void main(String args[]) {
}
} catch (Exception x) {
Trace.debug("caught exception during third batch");
x.printStackTrace();
Util.printException(x);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package com.amazon.corretto.benchmark.extremem;

import java.util.Collection;
import java.util.logging.Logger;
import java.util.logging.Level;

class Util {

Expand Down Expand Up @@ -31,6 +33,8 @@ class Util {

static final int InitialHashMapArraySize = 16;

static Logger logger = Logger.getGlobal();

/*
* Generic utilities
*/
Expand All @@ -44,14 +48,18 @@ static void internalError(String msg) {
static void fatalException(String msg, Throwable t) {
System.err.print("Intecepted fatal exception: ");
System.err.println(msg);
t.printStackTrace();
printException(t);
System.exit(-1);
}

static void printException(Throwable t) {
logger.log(Level.INFO, t.getMessage(), t);
}

// Use this service, without a message, when there is a strong
// likelihood that we are out of memory and any attempt to print
// a message will result in exceptions, thereby circumventing the exit
// attempt.
// attempt.
static void severeInternalError() {
System.exit(-1);
}
Expand Down Expand Up @@ -174,7 +182,7 @@ static void ephemeralRSBArray(ExtrememThread t, int len, int element_size) {
log.accumulate(LifeSpan.Ephemeral, MemoryFlavor.ArrayRSB, Grow,
len * element_size);
}

static void abandonEphemeralRSBArray(ExtrememThread t,
int len, int element_size) {
MemoryLog garbage = t.garbageLog();
Expand Down Expand Up @@ -242,7 +250,7 @@ static void tallyTreeMap(long tree_entries,
log.accumulate (ls, MemoryFlavor.ObjectReference, p, tree_entries * 5);
log.accumulate (ls, MemoryFlavor.ObjectRSB, p,
tree_entries * Util.SizeOfBoolean);
}
}

static void createTreeNode(ExtrememThread t, LifeSpan ls) {
Polarity Grow = Polarity.Expand;
Expand Down Expand Up @@ -315,7 +323,7 @@ static void abandonHashMap(ExtrememThread t, LifeSpan ls,
// Account for referenced array
garbage.accumulate(ls, MemoryFlavor.ArrayObject, Grow, 1);
garbage.accumulate(ls, MemoryFlavor.ArrayReference, Grow, capacity);

tallyHashNodes(garbage, ls, Grow, size);
}

Expand Down Expand Up @@ -345,7 +353,7 @@ static void tallyHashNodes(MemoryLog l, LifeSpan ls, Polarity p, int n) {
l.accumulate(ls, MemoryFlavor.PlainObject, p, n);
l.accumulate (ls, MemoryFlavor.ObjectReference, p, n * 3);
l.accumulate (ls, MemoryFlavor.ObjectRSB, p, n * Util.SizeOfInt);

}

// Usie addHashEntry and abandonHashEntry to adjust the number of
Expand All @@ -356,7 +364,7 @@ static void addHashEntry(ExtrememThread t, LifeSpan ls) {
Polarity Grow = Polarity.Expand;
// Identify that one node of HashMap representation has become garbage.
// Each node consists of a key, content, and next reference fields
// and an int hash_code field.
// and an int hash_code field.
log.accumulate (ls, MemoryFlavor.PlainObject, Grow, 1);
log.accumulate (ls, MemoryFlavor.ObjectReference, Grow, 3);
log.accumulate (ls, MemoryFlavor.ObjectRSB, Grow, Util.SizeOfInt);
Expand All @@ -367,7 +375,7 @@ static void abandonHashEntry(ExtrememThread t, LifeSpan ls) {
Polarity Grow = Polarity.Expand;
// Identify that one node of HashMap representation has become garbage.
// Each node consists of a key, content, and next reference fields
// and an int hash_code field.
// and an int hash_code field.
garbage.accumulate (ls, MemoryFlavor.PlainObject, Grow, 1);
garbage.accumulate (ls, MemoryFlavor.ObjectReference, Grow, 3);
garbage.accumulate (ls, MemoryFlavor.ObjectRSB, Grow, Util.SizeOfInt);
Expand Down Expand Up @@ -420,7 +428,7 @@ static void tallyHashMap(MemoryLog log, LifeSpan ls, Polarity p,
/*
* Memory accounting utilities for HashSet
*/

/* Account for the HashSet representations associated with name and
* descriptor indexes used for Product lookups. This accounting
* does not include memory to represent the individual Long
Expand Down Expand Up @@ -500,7 +508,7 @@ static int ephemeralStringBuilderAppend(ExtrememThread t,
}

// Discard the StringBuilder and its backing store. Allocate string
// and its backing store.
// and its backing store.
static void ephemeralStringBuilderToString(ExtrememThread t,
int count, int capacity) {
MemoryLog garbage = t.garbageLog();
Expand Down Expand Up @@ -746,4 +754,4 @@ static void tallyStrings(MemoryLog log, LifeSpan ls, Polarity p,
log.accumulate(ls, MemoryFlavor.ArrayObject, p, string_count);
log.accumulate(ls, MemoryFlavor.StringData, p, cumulative_len);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* The object store for long lived object. The objects are stored in a list of object lists. Objects from one list may
Expand Down Expand Up @@ -40,6 +42,8 @@ public class ObjectStore implements Runnable {
private AtomicLong currentSize;
private boolean running;

static Logger logger = Logger.getGlobal();

public ObjectStore(final int sizeLimitInMb) {
this(sizeLimitInMb, DEFAULT_PRUNE_RATIO, DEFAULT_RESHUFFLE_RATIO);
}
Expand Down Expand Up @@ -127,7 +131,7 @@ public void run() {

Thread.sleep(INTERVAL_IN_MS);
} catch (InterruptedException e) {
e.printStackTrace();
logger.log(Level.SEVERE, e.getMessage(), e);
System.exit(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand All @@ -29,6 +31,8 @@ public SimpleRunner(SimpleRunConfig config) {
this.config = config;
}

static Logger logger = Logger.getGlobal();

@Override
public void start() {
try {
Expand Down Expand Up @@ -58,7 +62,7 @@ public void start() {
r.get();
}
} catch (ExecutionException ex) {
ex.printStackTrace();
logger.log(Level.SEVERE, ex.getMessage(), ex);
printResult(-1);
System.exit(1);
}
Expand Down Expand Up @@ -181,7 +185,7 @@ public void run() {
}
} catch (IOException ioe) {
System.err.println("Cannot write to allocation log: " + allocationLogFile);
ioe.printStackTrace(System.err);
logger.log(Level.SEVERE, ioe.getMessage(), ioe);
} catch (InterruptedException iee) {
Thread.currentThread().interrupt();
}
Expand Down