Skip to content

Commit

Permalink
Optimisation for calculating the byte sum
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-lawrey committed Jan 22, 2016
1 parent 8f26591 commit 41cb5c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
Expand Up @@ -16,7 +16,10 @@

package net.openhft.chronicle.queue.impl;

import net.openhft.chronicle.bytes.*;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.bytes.MappedBytes;
import net.openhft.chronicle.bytes.ReadBytesMarshallable;
import net.openhft.chronicle.bytes.WriteBytesMarshallable;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.OS;
import net.openhft.chronicle.core.annotation.ForceInline;
Expand Down Expand Up @@ -212,14 +215,9 @@ public BufferAppender(@NotNull final EventLoop eventLoop,
}

};
Bytes bytes2 = NativeBytes.nativeBytes(128).unchecked(true);

eventLoop.addHandler(handler);
/*eventLoop.addHandler(() -> {
bytes2.clear();
ringBuffer.read(bytes2);
return true;
});
*/

eventLoop.addHandler(new EventHandler() {
@Override
public boolean action() throws InvalidEventHandlerException {
Expand Down
Expand Up @@ -495,6 +495,8 @@ private long read(@NotNull Bytes bytes, long offset, long len) {
//other words is that start of the data at the end of the ring and the remaining
//data at the start of the ring.
if (endOffSet >= offset) {
if (len > 1000)
System.out.println("len:" + len);
bytes.write(byteStore, offset, len);
return endOffSet;
}
Expand Down
Expand Up @@ -18,7 +18,6 @@

package net.openhft.chronicle.queue;

import net.openhft.affinity.Affinity;
import net.openhft.affinity.AffinityLock;
import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.bytes.NativeBytes;
Expand Down Expand Up @@ -66,7 +65,7 @@ public void test() throws IOException, InterruptedException {
Histogram histogram = new Histogram();
Histogram writeHistogram = new Histogram();

String path = "deleteme" + System.nanoTime() + ".q"; /*getTmpDir()*/
String path = "deleteme" + System.nanoTime() + ".q";
// String path = getTmpDir() + "/deleteme.q";

new File(path).deleteOnExit();
Expand All @@ -88,14 +87,9 @@ public void test() throws IOException, InterruptedException {
ExcerptTailer tailer = rqueue.createTailer();

Thread tailerThread = new Thread(() -> {

AffinityLock rlock = AffinityLock.acquireLock();
Bytes bytes = NativeBytes.nativeBytes(BYTES_LENGTH).unchecked(true);
// Bytes bytes = Bytes.allocateDirect(BYTES_LENGTH).unchecked(true);
AffinityLock lock = null;
try {
if (Boolean.getBoolean("enableTailerAffinity")) {
lock = Affinity.acquireLock();
}

while (true) {
try {
Expand All @@ -111,18 +105,15 @@ public void test() throws IOException, InterruptedException {
}
}
} finally {
if (lock != null) {
lock.release();
if (rlock != null) {
rlock.release();
}
}
}, "tailer thread");

Thread appenderThread = new Thread(() -> {
AffinityLock lock = null;
AffinityLock wlock = AffinityLock.acquireLock();
try {
if (Boolean.getBoolean("enableAppenderAffinity")) {
lock = Affinity.acquireLock();
}
Bytes bytes = Bytes.allocateDirect(BYTES_LENGTH).unchecked(true);

long next = System.nanoTime() + INTERVAL_US * 1000;
Expand All @@ -143,8 +134,8 @@ public void test() throws IOException, InterruptedException {
} catch (IOException e) {
e.printStackTrace();
} finally {
if (lock != null) {
lock.release();
if (wlock != null) {
wlock.release();
}
}
}, "appender thread");
Expand Down

0 comments on commit 41cb5c7

Please sign in to comment.