You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/04/08 09:41:21 UTC

[GitHub] [rocketmq] AdventurerJohn opened a new issue, #4137: Why doesn't rocketmq send files with sendfile like Kafka?

AdventurerJohn opened a new issue, #4137:
URL: https://github.com/apache/rocketmq/issues/4137

   Why doesn't rocketmq send files with sendfile like Kafka?
   
   
   对于MQ而言,无非就是生产者发送数据到MQ然后持久化到磁盘,之后消费者从MQ读取数据。
   
   对于RocketMQ来说这两个步骤使用的是mmap+write,而Kafka则是使用mmap+write持久化数据,发送数据使用sendfile。
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] qsrg commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
qsrg commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1103430103

   > @cserwen @lwclover As described in google's paper GFS, the side effect of zero-copy is that if the data is not in page cache, the page fault and disk reading(usually called cold data) will hang the netty thread. Which will cause delays in all requests.
   > 
   > For MQ, Keeping low latency of sending is very important, so for latency-sensitive applications, it is not suggested to use zero copy by default.
   
   Used mmap, the page fault and disk reading still exist. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] MatrixHB commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
MatrixHB commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1094273446

   > > 
   > 
   > 这是用了mmap,但是没有用到sendfile哇
   
   是的,这里ManyMessageTransfer重写了DefaultFileRegion的transferTo()方法,还是使用mmap,没有使用sendfile。曾经有个PR就对此做了修改:[#1933](https://github.com/apache/rocketmq/pull/1933)
   
   使用sendfile代替rocketmq,对读写性能会有多大的提升,是否带来其他的问题,未有定论。如果你有余力可以尝试优化和测试一把,可以加入rocketmq的性能优化SIG进一步探讨。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] AdventurerJohn commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
AdventurerJohn commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1107944828

   > 我理解是这样的,RocketMQ一个CommitLog会有多个Topic的消息,服务端需要做查找过滤,也就是需要对磁盘文件读取出来的结果做加工再返回,而Kafka一个segment文件是partition级别的,不需要处理直接返回给客户端就行,所以用sendfile会更合适:-D
   > 
   > 当然,我觉得也可以进行优化和测试,看看会有什么样的提升。
   
   有道理


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] RongtongJin commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
RongtongJin commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1094164675

   当transferMsgByHeap=false的时候,拉取消息会使用fileRegion的方式实现零拷贝
   
   https://github.com/apache/rocketmq/blob/47561bdd855ab381113d736b5c26a09c08da590b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java#L382-L408


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] AdventurerJohn closed issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
AdventurerJohn closed issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?
URL: https://github.com/apache/rocketmq/issues/4137


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] AdventurerJohn commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
AdventurerJohn commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1094168474

   > 
   
   这是用了mmap,但是没有用到sendfile哇


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lwclover commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
lwclover commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1092729471

   rocketmq也可以的,拉取消息的时候有配置是否使用sendfile方式,默认是不使用


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lwclover commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
lwclover commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1094452306

   > > 
   > 
   > 这是用了mmap,但是没有用到sendfile哇
   
   嗯,具体实现没有调用FileChannel的transferTo方法,还是mmap。
   我认为应该是rocketmq存储结构的原因。
   commitlog是多个topic读写,也就是针对单个topic读是小块文件。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] dongeforever commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
dongeforever commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1097512832

   @cserwen @lwclover 
   As described in google's paper GFS,  the side effect of zero-copy is that if the data is not in page cache, the page fault and disk reading(usually called cold data) will hang the netty thread. 
   Which will cause delays in all requests.
   
   For MQ, Keeping low latency of sending is very important, so for latency-sensitive applications, it is not suggested to use zero copy by default.
    


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] AdventurerJohn commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
AdventurerJohn commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1092763376

   > rocketmq也可以的,拉取消息的时候有配置是否使用sendfile方式,默认是不使用
   
   请问大佬是哪个配置啊,我没找到


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] AdventurerJohn commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
AdventurerJohn commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1092745365

   > RocketMQ也可以的,拉取消息的时候有配置是否使用sendfile方式,默认是不使用
   
   请教大佬,那为什么默认不使用呢?难道不是开启速度会更快一些吗?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] cserwen commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
cserwen commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1094487850

   我理解是这样的,RocketMQ一个CommitLog会有多个Topic的消息,服务端需要做查找过滤,也就是需要对磁盘文件读取出来的结果做加工再返回,而Kafka一个segment文件是partition级别的,不需要处理直接返回给客户端就行,所以用sendfile会更合适:-D
   
   当然,我觉得也可以进行优化和测试,看看会有什么样的提升。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] AdventurerJohn commented on issue #4137: Why doesn't rocketmq send files with sendfile like Kafka?

Posted by GitBox <gi...@apache.org>.
AdventurerJohn commented on issue #4137:
URL: https://github.com/apache/rocketmq/issues/4137#issuecomment-1107944782

   > > > 
   > > 
   > > 
   > > 这是用了mmap,但是没有用到sendfile哇
   > 
   > 嗯,具体实现没有调用FileChannel的transferTo方法,还是mmap。 我认为应该是rocketmq存储结构的原因,commitlog是多个topic读写,也就是针对单个topic读是小块文件。
   
   有道理


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org