lizhimins opened a new issue, #10521: URL: https://github.com/apache/rocketmq/issues/10521
### Before Creating the Enhancement Request - [x] I have confirmed that this should be classified as an enhancement rather than a bug/feature. ### Summary `ConsumeQueue.correctMinOffset` 对 mmap 文件做二分查找(随机访问),但内核默认 read-ahead 窗口在 NVMe 设备上非常激进,每次 page fault 预读大量不会用到的数据,产生周期性磁盘读脉冲。在云盘(读写带宽共享配额)场景下,读脉冲挤压 CommitLog 写入带宽,导致发送 RT 周期性毛刺。 通过在二分查找前后使用 `madvise(MADV_RANDOM)` / `madvise(MADV_NORMAL)` 抑制 read-ahead,可以消除读脉冲。增加配置开关 `correctMinOffsetMadviseEnable`,默认关闭。 ### Motivation 生产环境中观测到每 8-9 分钟一次磁盘读脉冲,峰值约 325 MB/s,持续约 3 秒。二分查找实际只需约 4MB 数据,但因 read-ahead 放大到约 975MB(~244 倍)。发送 p99 从正常的 ~4ms 跳至 ~26ms。 `posix_fadvise(FADV_RANDOM)` 不能解决此问题:Linux 2.6.35+ 的 mmap readahead 路径只检查 `VM_RAND_READ`(由 `madvise` 设置),不检查 `FMODE_RANDOM`(由 `fadvise` 设置)。 ### Describe the Solution You'd Like 1. 在 `correctMinOffset` 二分查找前,调用 `madvise(MADV_RANDOM)` 禁用 read-ahead 2. 在 finally 块中调用 `madvise(MADV_NORMAL)` 恢复,确保不影响后续顺序读 3. 增加配置开关 `correctMinOffsetMadviseEnable`(默认 false),控制是否启用 4. Windows 平台跳过(`madvise` 不可用),macOS/Linux 正常执行 5. JNA LibC 接口已存在,无需新增依赖 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
