Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Performance Improvement and Bug Fixes for the Tiered Storage Module #7878

Closed
1 task done
lizhimins opened this issue Mar 1, 2024 · 0 comments · Fixed by #7899 or #7962
Closed
1 task done

[Enhancement] Performance Improvement and Bug Fixes for the Tiered Storage Module #7878

lizhimins opened this issue Mar 1, 2024 · 0 comments · Fixed by #7899 or #7962

Comments

@lizhimins
Copy link
Member

lizhimins commented Mar 1, 2024

Before Creating the Enhancement Request

  • I have confirmed that this should be classified as an enhancement rather than a bug/feature.

Summary

Performance Improvement and Bug Fixes for the Tiered Storage Module

Motivation

This issue and PR attempt to address known issues within the tiered storage module of RocketMQ, maintaining the same storage format to support in-place upgrades. In the current implementation, the upload process experiences backpressure and lock contention. The new version of the tiered storage module uses asynchronous writes, with the actual performance tripling. With tiered storage enabled, the broker CPU usage is reduced by 25% under the same traffic load. Across two significant commits, the unit test coverage has improved from 60% to 77%, and the line coverage has reached 87% in the current version.

本 issue 和 pr 尝试修复 RocketMQ 中分级存储模块的已知问题,保持存储格式不变以支持原地升级。当前实现上传部分存在反压和锁竞争导致性能不佳。该提交中分级存储模块写性能提升3倍,相同流量下(开启分级存储特性时) broker cpu 降低 25%。经过几个迭代,单测覆盖率从 60% 到当前版本行覆盖率 87%。

Additional Context

The functions of each component

  1. org.apache.rocketmq.tieredstore.common
    • AppendResult 删除了无效返回值,增加行为注释
    • GetMessageResultExt 包裹类,携带 cq 中解析的 tag code 作为上下文返回,支持消息过滤
    • SelectBufferResult 包裹类,包装取回的消息缓存,并进行请求计数用作告警
  2. org.apache.rocketmq.tieredstore.util 减少了不必要的对象暴露
  3. org.apache.rocketmq.tieredstore.provider
    • FileSegment 文件段的实现,提交失败时行为大幅简化。
    • FileSegmentFactory 工厂类,用来生成文件段
    • MemoryFileSegment 和 PosixFileSegment 去除无法访问的逻辑,重构实现。
    • Stream 部分 CommitLogInputStream,FileSegmentInputStreamFactory
  4. org.apache.rocketmq.tieredstore.metadata
    • 元数据管理 json 实现数据格式不变,引入 rocksdb 实现。
  5. org.apache.rocketmq.tieredstore.file
    • FlatAppendFile.java 通过写时复制减少锁竞争,提升性能。修复异常宕机叠加文件切换时前一个文件可能没有持久化成功的边界条件问题。
    • FlatCommitLogFile.java 重构了强制 rolling 切换文件和计算 min offset 的方式。
    • FlatConsumeQueueFile.java 支持以非 0 方式初始化首个文件,修复宕机等异常情况下的问题。
    • FlatFileFactory.java 工厂类,产生上述几种类型的文件
    • FlatFileInterface.java 和 FlatMessageFile.java,关联数据流和消息。
    • FlatFileStore.java 通过 Map 管理多个实际队列。
  6. org.apache.rocketmq.tieredstore.index
    • 修复 compact 逻辑中对于时间范围的处理逻辑问题。
    • 修复以乱序微批方式写入时,查询时数据处于文件边界导致查询不到的问题。
  7. org.apache.rocketmq.tieredstore.core
    • MessageStoreDispatcherImpl.java 重构了,大幅减少了内存使用和数据复制,以攒批和纯异步的方式写出,相同流量下性能提升 3 倍以上。
    • MessageStoreFetcher.java 重构了,缓存方案变更,彻底避免 oom 问题。
    • MessageStoreTopicFilter.java 过滤系统 topic 和在黑名单中的 topic。
  8. org.apache.rocketmq.tieredstore.TieredMessageStore
    存储插件的引导与代理,去除单例和不合理的反射。

image

No response

lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 11, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 11, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 15, 2024
lizhimins added a commit that referenced this issue Mar 18, 2024
…orage Module (#7899)

Performance Improvement and Bug Fixes for the Tiered Storage Module
dingshuangxi888 added a commit to dingshuangxi888/rocketmq that referenced this issue Mar 18, 2024
drpmma pushed a commit to drpmma/rocketmq that referenced this issue Mar 19, 2024
drpmma pushed a commit to drpmma/rocketmq that referenced this issue Mar 19, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 25, 2024
lizhimins added a commit to lizhimins/rocketmq that referenced this issue Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant