Optimisation in Map perf test.

This commit is contained in:
Peter Lawrey
2014-12-05 23:55:40 +02:00
parent 87a20b4db9
commit 345496c84d
5 changed files with 31 additions and 11 deletions
@@ -0,0 +1,17 @@
package net.openhft.chronicle.hash.replication;
import java.net.InetSocketAddress;
public class TcpInetSocketAddress extends InetSocketAddress {
private final String toString;
public TcpInetSocketAddress(String hostname, int port) {
super(hostname, port);
toString = super.toString();
}
@Override
public String toString() {
return toString;
}
}
@@ -70,8 +70,12 @@ public final class TcpTransportAndNetworkConfig implements Serializable {
throw new IllegalArgumentException("endpoint=" + endpoint
+ " can not point to the same port as the server");
}
Set<InetSocketAddress> s = new HashSet<>();
for (InetSocketAddress endpoint : endpoints) {
s.add(new TcpInetSocketAddress(endpoint.getHostName(), endpoint.getPort()));
}
return new TcpTransportAndNetworkConfig(
serverPort, unmodifiableSet(new HashSet<InetSocketAddress>(endpoints)),
serverPort, unmodifiableSet(s),
DEFAULT_PACKET_SIZE,
false, // autoReconnectedUponDroppedConnection
ThrottlingConfig.noThrottling(),
@@ -1491,7 +1491,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
private <R> R fetchObject(Class<R> rClass, final EventId eventId, K key, V... values) {
private <R> R fetchObject(Class<R> rClass, final EventId eventId, K key, V value) {
final long startTime = System.currentTimeMillis();
ThreadLocalCopies copies;
@@ -1505,9 +1505,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
: writeEventAnSkip(eventId);
copies = writeKey(key);
for (V value : values) {
copies = writeValue(value, copies);
}
copies = writeValue(value, copies);
transactionId = blockingSend(sizeLocation, startTime);
} finally {
outBytesLock.unlock();
@@ -1689,9 +1689,8 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
return (int) (sizeInBytes / entrySize) + 1;
}
private <KB, KBI, MKBI extends MetaBytesInterop<KB, ? super KBI>, RV>
RV acquire(
@Nullable ThreadLocalCopies copies, final @Nullable SegmentState segmentState,
<KB, KBI, MKBI extends MetaBytesInterop<KB, ? super KBI>, RV>
RV acquire(@Nullable ThreadLocalCopies copies, final @Nullable SegmentState segmentState,
MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize,
InstanceOrBytesToInstance<KB, K> toKey,
ReadValue<RV> readValue, RV usingValue, InstanceOrBytesToInstance<RV, V> toValue,
+5 -3
View File
@@ -23,12 +23,12 @@ public class BGChronicleTest {
public static final int CHRONICLE_HEARTBEAT_SECONDS = 5;
public static final int READ_RATIO = Integer.getInteger("readRatio", 2);
public static final int CLIENTS = Integer.getInteger("clients", Math.max(1, Runtime.getRuntime().availableProcessors() - 2));
public static final int CLIENTS = Integer.getInteger("clients", Math.max(1, Runtime.getRuntime().availableProcessors() - 1));
// public static final boolean BUSY_WAIT = Boolean.parseBoolean(System.getProperty("busyWait",
// "" + (CLIENTS < Runtime.getRuntime().availableProcessors())));
public static final int REPLICAS = Integer.getInteger("replicas", 1);
public static final long KEYS = Long.getLong("keys", 100_000L);
public static final long MESSAGES = Long.getLong("messages", 100_000 + KEYS * 2);
public static final long MESSAGES = Long.getLong("messages", 1000_000 + KEYS * 10);
public static final long MAX_RATE = Long.getLong("maxRate", 50000);
public static final String DEFAULT_HOST = "localhost";
public static final int DEFAULT_PORT = 9050;
@@ -235,15 +235,17 @@ public class BGChronicleTest {
// if (BUSY_WAIT)
// while (System.nanoTime() < next) ;
// 100 possible values for the first byte.
long start = System.nanoTime();
long start;
key[0] = b;
if (rnd.nextInt(READ_RATIO + 1) == 0) {
// puts
value[0] = b;
start = System.nanoTime();
map.put(key, value);
} else {
//gets
start = System.nanoTime();
map.get(key);
}
long time = System.nanoTime() - start;