You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/03/22 02:01:45 UTC
[james-project] 14/29: JAMES-3715 IMAP: Improve threading model
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2dffa1342f445e81d96f9eb02ad14e9177490b46
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Mar 10 15:56:22 2022 +0700
JAMES-3715 IMAP: Improve threading model
We can do framing + chunck writing on the eventloop now.
This prevents us from always switching on a distinct thread for
these operations and dramatically improves performance.
---
.../java/org/apache/james/imapserver/netty/IMAPServer.java | 6 +++---
.../apache/james/imapserver/netty/ImapRequestFrameDecoder.java | 10 +++-------
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
index fda2bdb..f689024 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServer.java
@@ -230,7 +230,7 @@ public class IMAPServer extends AbstractConfigurableAsyncServer implements ImapC
// Add the text line decoder which limit the max line length,
// don't strip the delimiter and use CRLF as delimiter
// Use a SwitchableDelimiterBasedFrameDecoder, see JAMES-1436
- pipeline.addLast(getExecutorGroup(), FRAMER, getFrameHandlerFactory().create(pipeline));
+ pipeline.addLast(FRAMER, getFrameHandlerFactory().create(pipeline));
Encryption secure = getEncryption();
if (secure != null && !secure.isStartTLS()) {
@@ -243,10 +243,10 @@ public class IMAPServer extends AbstractConfigurableAsyncServer implements ImapC
}
pipeline.addLast(CONNECTION_COUNT_HANDLER, getConnectionCountHandler());
- pipeline.addLast(getExecutorGroup(), CHUNK_WRITE_HANDLER, new ChunkedWriteHandler());
+ pipeline.addLast(CHUNK_WRITE_HANDLER, new ChunkedWriteHandler());
pipeline.addLast(getExecutorGroup(), REQUEST_DECODER, new ImapRequestFrameDecoder(decoder, inMemorySizeLimit,
- literalSizeLimit, getExecutorGroup(), maxLineLength));
+ literalSizeLimit, maxLineLength));
pipeline.addLast(getExecutorGroup(), CORE_HANDLER, createCoreHandler());
}
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
index 027fd3c..fb5d363 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
@@ -45,7 +45,6 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.ByteToMessageDecoder;
-import io.netty.util.concurrent.EventExecutorGroup;
/**
@@ -62,15 +61,12 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
private final int inMemorySizeLimit;
private final int literalSizeLimit;
private final Deque<ChannelInboundHandlerAdapter> behaviourOverrides = new ConcurrentLinkedDeque<>();
- private final EventExecutorGroup eventExecutors;
- private int maxFrameLength;
+ private final int maxFrameLength;
- public ImapRequestFrameDecoder(ImapDecoder decoder, int inMemorySizeLimit, int literalSizeLimit, EventExecutorGroup eventExecutors,
- int maxFrameLength) {
+ public ImapRequestFrameDecoder(ImapDecoder decoder, int inMemorySizeLimit, int literalSizeLimit, int maxFrameLength) {
this.decoder = decoder;
this.inMemorySizeLimit = inMemorySizeLimit;
this.literalSizeLimit = literalSizeLimit;
- this.eventExecutors = eventExecutors;
this.maxFrameLength = maxFrameLength;
}
@@ -224,7 +220,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
if (ctx.channel().pipeline().get(FRAMER) == null) {
ctx.channel().config().setAutoRead(false);
ctx.channel().eventLoop().execute(() ->
- ctx.channel().pipeline().addBefore(eventExecutors, REQUEST_DECODER, FRAMER,
+ ctx.channel().pipeline().addBefore(REQUEST_DECODER, FRAMER,
new SwitchableLineBasedFrameDecoder(ctx.channel().pipeline(), maxFrameLength, false)));
ctx.channel().config().setAutoRead(true);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org