深入理解SPDK 之二: 消息和无锁队列

网友投稿 479 2022-10-14

深入理解SPDK 之二: 消息和无锁队列

并发理论

期望: 随着硬件的线性增加,性能也线性增加;

传统 锁 的优点: 无锁 到有锁 扩展的方便; 锁直接加在共享数据的前面; 缺点:随着系统内线程的增加,数据和临界段的竞争越来越激烈,而且多个线程可能处于不同物理core,频繁竞争导致剧烈的L1 cache 失效。 SPDK的做法:各管各妈;你看我娃

** 各管各妈

SPDK takes a different approach altogether. Instead of placing shared data in a global location that all threads access after acquiring a lock, SPDK will often assign that data to a single thread.

** 你看我娃When other threads want to access the data, they pass a message to the owning thread to perform the operation on their behalf.

消息传递架构

libspdk_thread.a: SPDK's thread abstraction, located in; spdk_thread: 线程执行的抽象 spdk_poller: 执行的线程内被周期执行的函数的抽象 spdk_allocate_thread() :分配spdk 线程参数是三个函数指针: 給其他线程提供的为即将创建的线程传递参数的函数指针;給其他线程提供的启动当前线程poller的函数接口; 停止当前线程poller的函数接口 spdk_io_device: 之前的含义是 支持无锁多队列IO请求的设备,后来泛指is any pointer, whose uniqueness is predicated only on its memory address spdk_io_channel: 之前的含义是指 給特别为上面IO设备分配的线程;现在是指和某个spdk_io_device绑定的per-thread的上下文context.

spdk 事件框架

现在直接调用 spdk_app_start() 为你打理所有下面的准备工作:

spawning one thread per core, pinning each thread to a unique core, allocating lockless rings between the threads for message passing

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:ceph 集群部署
下一篇:Spring Boot 底层原理基础深度解析
相关文章

 发表评论

暂时没有评论,来抢沙发吧~