Use 1000 as default value for the max composite buffer components. This safe a lot of byte copies and so speed up every decoder that extends FrameDecoder. See #435
This commit is contained in:
parent
bf23828734
commit
91d5c9a0a6
@ -179,11 +179,13 @@ import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
||||
*/
|
||||
public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implements LifeCycleAwareChannelHandler {
|
||||
|
||||
public static final int DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS = 1000;
|
||||
|
||||
private boolean unfold;
|
||||
protected ChannelBuffer cumulation;
|
||||
private volatile ChannelHandlerContext ctx;
|
||||
private int copyThreshold;
|
||||
private int maxCumulationBufferComponents = 4;
|
||||
private int maxCumulationBufferComponents = DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS;
|
||||
|
||||
protected FrameDecoder() {
|
||||
this(false);
|
||||
@ -252,7 +254,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
* Returns the maximum number of components in the cumulation buffer. If the number of
|
||||
* the components in the cumulation buffer exceeds this value, the components of the
|
||||
* cumulation buffer are consolidated into a single component, involving memory copies.
|
||||
* The default value of this property is {@code 4}.
|
||||
* The default value of this property {@link #DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS}.
|
||||
*/
|
||||
public final int getMaxCumulationBufferComponents() {
|
||||
return maxCumulationBufferComponents;
|
||||
@ -262,7 +264,8 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
* Sets the maximum number of components in the cumulation buffer. If the number of
|
||||
* the components in the cumulation buffer exceeds this value, the components of the
|
||||
* cumulation buffer are consolidated into a single component, involving memory copies.
|
||||
* The default value of this property is {@code 4} and its minimum allowed value is {@code 2}.
|
||||
* The default value of this property is {@link #DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS}
|
||||
* and its minimum allowed value is {@code 2}.
|
||||
*/
|
||||
public final void setMaxCumulationBufferComponents(int maxCumulationBufferComponents) {
|
||||
if (maxCumulationBufferComponents < 2) {
|
||||
|
@ -55,7 +55,6 @@ public class CompatibleMarshallingDecoder extends ReplayingDecoder<VoidEnum> {
|
||||
public CompatibleMarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize) {
|
||||
this.provider = provider;
|
||||
this.maxObjectSize = maxObjectSize;
|
||||
setMaxCumulationBufferComponents(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,7 +57,6 @@ public class MarshallingDecoder extends LengthFieldBasedFrameDecoder {
|
||||
public MarshallingDecoder(UnmarshallerProvider provider, int maxObjectSize) {
|
||||
super(maxObjectSize, 0, 4, 0, 4);
|
||||
this.provider = provider;
|
||||
setMaxCumulationBufferComponents(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,6 @@ public class CompatibleObjectDecoder extends ReplayingDecoder<CompatibleObjectDe
|
||||
*/
|
||||
public CompatibleObjectDecoder() {
|
||||
super(CompatibleObjectDecoderState.READ_HEADER);
|
||||
setMaxCumulationBufferComponents(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,6 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
|
||||
public ObjectDecoder(int maxObjectSize, ClassResolver classResolver) {
|
||||
super(maxObjectSize, 0, 4, 0, 4);
|
||||
this.classResolver = classResolver;
|
||||
setMaxCumulationBufferComponents(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user