C++高性能并行编程与优化 - 课件 - 05 C++11 开始的多线程编程
std::async • std::async 接受一个带返回值的 lambda ,自身返回一个 std::future 对象 。 • lambda 的函数体将在另一个线程里执行 。 • 接下来你可以在 main 里面做一些别的事 情, download 会持续在后台悄悄运行。 • 最后调用 future 的 get() 方法,如果此时 download 还没完成,会等待 download 完成,并获取 则可以指定一个最长等待时间, 用 chrono 里的类表示单位。他会返回一个 std::future_status 表示等待是否成功。 • 如果超过这个时间线程还没有执行完毕,则放 弃等待,返回 future_status::timeout 。 • 如果线程在指定的时间内执行完毕,则认为等 待成功,返回 future_status::ready 。 • 同理还有 wait_until() 其参数是一个时间点。 d 做参数 • std::async 的第一个参数可以设为 std::launch::deferred ,这时不会创建一个 线程来执行,他只会把 lambda 函数体内 的运算推迟到 future 的 get() 被调用时。 也就是 main 中的 interact 计算完毕后。 • 这种写法, download 的执行仍在主线程 中,他只是函数式编程范式意义上的异步 ,而不涉及到真正的多线程。可以用这个0 码力 | 79 页 | 14.11 MB | 1 年前3Await-Tree Async Rust 可观测性的灵丹妙药 - 赵梓淇
• 无栈协程 Async Rust 回顾 Rust 的无栈协程抽象 — Future Async Rust 回顾 • 通过 poll 驱动的状态机 • 组合嵌套为调度单元: Task • async fn 语法糖 Async Rust 观测与调试的痛点 Async Rust 回顾 • 特性: Future 灵活的可组合性 • 任意定制 Poll 的执行逻辑 (Join / Select 设计原理与实现 2 回顾 Async Rust 的设计与痛点 1 Await-Tree 的 应用与真实案例 3 设计目标 Await Tree 的设计原理与实现 • 追踪关键 Future 的生命周期和控制流 • Init, First Poll, Pending, Next Poll, Ready, Cancel • 实时将 Task 的执行状态维护为一棵树 • 显示目前正在阻塞 Tree 的设计原理与实现 设计细节 Await Tree 的设计原理与实现 • 充分理解 Future 生命周期中的控制流 Await Tree 的维护 Await Tree 的设计原理与实现 • 初始状态 Await Tree 的维护 Await Tree 的设计原理与实现 • Future 构造 Await Tree 的维护 Await Tree 的设计原理与实现 • Select0 码力 | 37 页 | 8.60 MB | 1 年前3CeresDB Rust 生产实践 任春韶
CeresDB Rust 生产实践 任春韶 CeresDB 核心开发者 蚂蚁集团技术专家 CeresDB 介绍 Rust 生产实践 - Tokio Preemption - Future Cancellation 目录 CeresDB – 历程 2018.02 2018.10 2019.02 ~ 2020.11 2021.9 自研存储引擎 1.0.0 版本发布 Preemption - Future Cancellation Rust 生产实践 生产实践 – Tokio 为什么使用 Tokio ? 1. 业界使用最广泛,测试齐全。 2. Tokio 支持 async/await ,提供了高效的异步锁、异步队列等。 3. Tokio 社区支持好。 生产实践 – Tokio Rust future preemption https://docs spends a long time without reaching an .await will prevent other tasks from running. 生产实践 – Future 循环 Run Return https://rust-lang.github.io/async-book/04_pinning/01_chapter.html#why-pinning https://doc0 码力 | 22 页 | 6.95 MB | 1 年前3Rust 异步并发框架在移动端的应用 - 陈明煜
只提供异步所需的基本特性: Future async / await Waker asyn c Future Waker poll Syntax sugar wake await Rust 异步机制 Asynchronous Rust Rust 异步机制 Asynchronous Rust Waker Task Future task Queue wake wake Worker Future.poll() Reactor fd fd listen listen find 现有并发框架 Third Party Runtime 目前 Rust 社区最广泛使用的事件 驱动型调度框架,擅长处理大量异 步 IO 的场景。具有非常强大的生 态。 tokio 第一个适配 Rust async/await 原语 的运行时库,与 tokio 类似支持异步0 码力 | 25 页 | 1.64 MB | 1 年前3基于 Rust Arrow Flight 的物联网和时序数据传输及转换工具 霍琳贺
with metadata • RecordBatch • IPC Stream Tonic + Arrow Flight • 以流为中心的 RPC 框架 Tokio - Future and .abort() • Future • JoinHandle::abort() Tokio - Cancel • Case 2: tokio::select with stream::iter • Case 提交耗时任务 • C FFI 调用时,要关注上下文的线程安全性。 • 多个运行时之间使用 Channel 通信,降低锁使用范围。 Tokio - Graceful Stop • futures::future::Abortable 可用于短路一个 stream • tokio_util::sync::CancellationToken 可用于向一个或多个任务发出取 消信号, Task 内使用 tokio::select0 码力 | 29 页 | 2.26 MB | 1 年前3绕过conntrack,使用eBPF增强 IPVS优化K8s网络性能
Problems with K8s Service How to optimize 02 Comparison with industry Performance measurement 03 04 Future work 05 06 Lessons from eBPF What is K8s Service • It exposes a set of pods via VIP using a load from_size, __be32 * to, u32 to_size); pass skb->len to bpf_csum_diff() the verifier reports error Future work • Open source • The modification to IPVS is already open source • https://github.com/Ten0 码力 | 24 页 | 1.90 MB | 1 年前3Harbor Deep Dive - Open source trusted cloud native registry
2.0 license An open source trusted cloud native registry project HARBOR More integrations in future Harbor Project History Harbor Community Harbor Users and Partners (selected) x x Main Features0 码力 | 15 页 | 8.40 MB | 1 年前3sync clickhouse with mysql mongodb
UUID3 2 Bob2 3 2019-10-03 00:00:00 BONUS Time travel history state Create Update Update Delete Future ● Auto configure through web ● Auto deploy on Kubernetes ● Open source? ● Github: kevwan Q&A Thanks0 码力 | 38 页 | 2.25 MB | 1 年前3基于Rust-vmm实现Kubernetes运行时
untrusted-workload: "true" spec: containers: - name: nginx image: nginx EOT Rust- VMM Demo Future Works • Extend Rust-VMM to support networking and storage • Security policy integration • Develop0 码力 | 27 页 | 34.17 MB | 1 年前3THE FIRST EXPLORATION OF PROJECT SPARROW
Practicing Sparrow A good summary from "Rust support in seL4 userspace : Present and future", Nick Spinale, seL4 Summit 2022: 2.1 Rust-centric Pop!_OS 2.1.1 Rust-Written Desktop0 码力 | 68 页 | 13.14 MB | 1 年前3
共 15 条
- 1
- 2