Skip to content

Instantly share code, notes, and snippets.

View normanmaurer's full-sized avatar
🤙

Norman Maurer normanmaurer

🤙
View GitHub Profile
@Test
public void testRefCnt() {
CompositeByteBuf comp = compositeBuffer();
ByteBuf buf1 = directBuffer(2, 2);
ByteBuf buf2 = directBuffer(2, 2);
comp.addComponent(buf1);
comp.addComponent(buf2);
//comp.writeInt(1);
//assertEquals(1, comp.getInt(0));
assertTrue(comp.release());
@State(Scope.Benchmark)
@Warmup(iterations = 10)
@Measurement(iterations = 25)
public class AbstractByteBufBenchmark extends AbstractMicrobenchmark {
private ByteBuf asciiBuffer;
private ByteBuf utf8Buffer;
@Setup
public void setup() {
asciiBuffer = Unpooled.directBuffer(512);
Benchmark Mode Samples Score Score error Units
i.n.m.b.ByteBufUtilBenchmark.writeAsciiCharSequence thrpt 50 9477142,158 318275,116 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiCharSequenceViaArray thrpt 50 3316136,435 61074,582 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiCharSequenceViaArrayWrapped thrpt 50 3218859,881 86846,872 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiCharSequenceWrapped thrpt 50 3364902,419 96887,413 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiString thrpt 50 9244736,846 342537,642 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiStringViaArray thrpt 50 4704437,346 148734,182 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiStringViaArrayWrapped thrpt 50 4682576,520 132453,312 ops/s
i.n.m.b.ByteBufUtilBenchmark.writeAsciiStringWrapped
diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java
index 906974c..2128094 100644
--- a/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java
+++ b/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java
@@ -240,46 +240,62 @@ public class NioSocketChannel extends AbstractNioByteChannel implements io.netty
@Override
protected void doWrite(ChannelOutboundBuffer in) throws Exception {
for (;;) {
- // Do non-gathering write for a single buffer case.
- final int msgCount = in.size();
@Override
public ByteBuf capacity(int newCapacity) {
ensureAccessible();
if (newCapacity < 0 || newCapacity > maxCapacity()) {
throw new IllegalArgumentException("newCapacity: " + newCapacity);
}
int readerIndex = readerIndex();
int writerIndex = writerIndex();
@Override
public ByteBuf capacity(int newCapacity) {
ensureAccessible();
if (newCapacity < 0 || newCapacity > maxCapacity()) {
throw new IllegalArgumentException("newCapacity: " + newCapacity);
}
int readerIndex = readerIndex();
int writerIndex = writerIndex();
[junit] ... 3 common frames omitted
[junit] ERROR 09:29:40 Exception in thread Thread[pool-10-thread-30,5,main]
[junit] com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1 (com.datastax.driver.core.TransportException: [/127.0.0.1] Channel has been closed))
[junit] ERROR 09:27:36 Error parsing schema options for table CounterCacheSpace.Counter1: Cluster.get
Metadata().getKeyspace("CounterCacheSpace").getTable("Counter1").getOptions() will return null
[junit] java.lang.IllegalArgumentException: populate_io_cache_on_flush is not a column defined in thi
s metadata
[junit] at com.datastax.driver.core.ColumnDefinitions.getAllIdx(ColumnDefinitions.java:273) ~[cas
sandra-driver-core-2.0.1.jar:na]
[junit] at com.datastax.driver.core.ColumnDefinitions.getFirstIdx(ColumnDefinitions.java:279) ~[c
assandra-driver-core-2.0.1.jar:na]
[junit] at com.datastax.driver.core.ArrayBackedRow.isNull(ArrayBackedRow.java:56) ~[cassandra-dri
ver-core-2.0.1.jar:na]
[nmaurer@xxx]~% wrk/wrk -H 'Host: localhost' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Connection: keep-alive' -d 120 -c 256 -t 16 --pipeline 256 http://xxx.xxx.xxx.xxx:8080/plaintext
Running 2m test @ http://xxx.xxx.xxx.xxx:xxx/plaintext
16 threads and 256 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 26.41ms 74.30ms 1.71s 98.21%
Req/Sec 196.44k 29.40k 300.45k 84.58%
373263661 requests in 2.00m, 50.41GB read
Requests/sec: 3110547.69
Transfer/sec: 430.14MB
estSpdyEchoNotAutoRead(io.netty.testsuite.transport.socket.SocketSpdyEchoTest) Time elapsed: 0.003 sec <<< ERROR!
java.nio.channels.CancelledKeyException: null
at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73)
at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:82)
at io.netty.channel.socket.nio.NioSocketChannel.doConnect(NioSocketChannel.java:194)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.connect(AbstractNioChannel.java:201)
at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1177)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeConnectNow(ChannelHandlerInvokerUtil.java:117)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeConnect(DefaultChannelHandlerInvoker.java:238)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:411)