简体   繁体   English

如果 CompositeByteBuf 中的组件数量超过“maxNumComponents”,为什么 Netty 的 CompositeByteBuf 会自动合并

[英]Why Netty's CompositeByteBuf consolidates automatically if the number of components in CompositeByteBuf exceeds 'maxNumComponents'

I'm trying to understand why CompositeByteBuf, consolidates if the number of components in the compositebytebuf becomes more than 'maxNumComponents' while adding component ?我试图理解为什么 CompositeByteBuf,如果在添加组件时CompositeBytebuf 中的组件数量变得超过 'maxNumComponents' 合并?

This consolidation involves copy operations .这种整合涉及复制操作 My questions are -我的问题是——

  1. why CompositeByteBuf is doing this consolidation automatically if the number of components is greater than 'maxNumComponents'?如果组件数量大于“maxNumComponents”,为什么 CompositeByteBuf 会自动进行此合并? what is the advantage in doing so?这样做有什么好处?
  2. Will there be any disadvantage if we explicitly set 'maxNumComponents' to very high number, so that consolidation will not be triggered.如果我们将 'maxNumComponents' 显式设置为非常高的数字,这样不会触发合并,会不会有什么坏处。

It does this because once you have a lot of buffers in a CompositeByteBuf accessing things on a specific index can for example become very slow.这样做是因为一旦CompositeByteBuf有很多缓冲区,访问特定索引上的内容可能会变得非常慢。

If this is a problem for you or not depends highly on the use-case.如果这对您来说是一个问题,在很大程度上取决于用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM