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:48 UTC
[james-project] 17/29: JAMES-3715 ImapRequestFrameDecoder avoid calling ChannelPipeline::get on each request
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 98af5c6cf32bafe21e3639da8f7c711a819c4951
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Mar 11 10:01:25 2022 +0700
JAMES-3715 ImapRequestFrameDecoder avoid calling ChannelPipeline::get on each request
Pipeline get was taking up to 4.25% of IMAP request decoding time. We can
easily handle state in ImapRequestFrameDecoder to not need this.
---
.../org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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 fb5d363..968178c 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
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.james.imap.api.ImapMessage;
import org.apache.james.imap.api.ImapSessionState;
@@ -62,6 +63,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
private final int literalSizeLimit;
private final Deque<ChannelInboundHandlerAdapter> behaviourOverrides = new ConcurrentLinkedDeque<>();
private final int maxFrameLength;
+ private final AtomicBoolean framingEnabled = new AtomicBoolean(true);
public ImapRequestFrameDecoder(ImapDecoder decoder, int inMemorySizeLimit, int literalSizeLimit, int maxFrameLength) {
this.decoder = decoder;
@@ -214,10 +216,12 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
ctx.channel().config().setAutoRead(false);
ctx.channel().eventLoop().execute(() -> ctx.channel().pipeline().remove(FRAMER));
ctx.channel().config().setAutoRead(true);
+ framingEnabled.set(false);
}
public void enableFraming(ChannelHandlerContext ctx) {
- if (ctx.channel().pipeline().get(FRAMER) == null) {
+ if (!framingEnabled.get()) {
+ framingEnabled.set(true);
ctx.channel().config().setAutoRead(false);
ctx.channel().eventLoop().execute(() ->
ctx.channel().pipeline().addBefore(REQUEST_DECODER, FRAMER,
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org