22 Star 23 Fork 70

src-openEuler / ceph

 / 详情

mempool.h函数pick_a_shard有明显的性能问题 上游社区新版本已解决

已完成
缺陷
创建于  
2021-12-28 16:17

上游社区已修正此问题:
https://github.com/ceph/ceph/pull/39057/files
【标题描述】我们在ceph client端的测试中发现adjust_count热点占40%,注释后性能大幅提升
【问题复现步骤】
操作步骤:SPDK启动拉起ceph虚拟盘,在虚拟机里使用fio测试虚拟盘的IO性能,在host上perf抓取vhost进程的热点,发现 adjust_count占比非常高。
adjust_count代码:

//src/include/mempool.h
shard_t* pick_a_shard() {
    // Dirt cheap, see:
    //   http://fossies.org/dox/glibc-2.24/pthread__self_8c_source.html
    size_t me = (size_t)pthread_self();
    size_t i = (me >> 3) & ((1 << num_shard_bits) - 1);
    return &shard[i];
  }
//src/common/mempool.cc
void mempool::pool_t::adjust_count(ssize_t items, ssize_t bytes)
{
  shard_t *shard = pick_a_shard();
  shard->items += items;
  shard->bytes += bytes;
}

其中问题主要在pick_a_shard函数中,它先获取me = pthread_self(),然后me右移3bit取低5bit作为shard数组下标,这里pthread_self()返回的是线程在进程内的唯一标识ID,这里vhost进程内所有线程获取的id低12bit都是一致的(4K page对齐),所以vhost里所有线程都选中了相同的shard,多线程间产生大量的原子写竞争。
复现概率:必现

出现问题时的perf top截图:
输入图片说明

评论 (2)

liqiang 创建了缺陷

Hi liqiang9102, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: sig-ceph, and any of the maintainers: @chixinze , @liuzhiqiang

openeuler-ci-bot 添加了
 
sig/sig-ceph
标签

感谢提出该问题。
欢迎提pr来解决该问题

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(3)
5329419 openeuler ci bot 1632792936 5592035 liuzhiqiang26 1594357385
1
https://gitee.com/src-openeuler/ceph.git
git@gitee.com:src-openeuler/ceph.git
src-openeuler
ceph
ceph

搜索帮助