ワンクリックで
py2rs-review-r3-io-concurrency
[DRAFT] 第 3 轮审查:消除阻塞 IO 与不必要等待。引入 async、tokio、rayon。允许 IO 层面大改;允许算法逻辑小改以匹配 IO。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
[DRAFT] 第 3 轮审查:消除阻塞 IO 与不必要等待。引入 async、tokio、rayon。允许 IO 层面大改;允许算法逻辑小改以匹配 IO。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Convert Markdown with LaTeX math, images, and tables into a polished PDF. Two rendering engines: (1) weasyprint — pure Python, no browser needed; (2) chromium — best for matrices/bmatrix/pmatrix/vmatrix and complex formulas. Supports Chinese/Japanese fonts. Can chain after ocr-md-polish for a complete OCR→clean→PDF workflow.
Burn core framework - Provides tensor operations, automatic differentiation, and neural network building blocks for Rust deep learning.
Burn CUDA backend - High-performance NVIDIA GPU acceleration. Provides optimal performance for NVIDIA hardware.
Burn Metal backend - Apple GPU acceleration for macOS and iOS. Optimized for Apple Silicon and Intel-based Macs.
Burn NdArray backend - CPU-based tensor operations using Rust's ndarray crate. Ideal for development, testing, and lightweight inference.
Burn ONNX support - Import ONNX models into Burn for inference on any backend. Supports compile-time code generation and runtime loading.
| name | py2rs-review-r3-io-concurrency |
| description | [DRAFT] 第 3 轮审查:消除阻塞 IO 与不必要等待。引入 async、tokio、rayon。允许 IO 层面大改;允许算法逻辑小改以匹配 IO。 |
DRAFT(草稿状态)。是否用 tokio、是否引入 rayon、是否真的需要 async,都可能在实战里被推翻。
rs/src/main.rs 的 #[tokio::main] async fn main() 模板rs/src/ 下一个 http.rs / fs.rs / db.rs 的 async 化示例Cargo.toml 中 tokio = { version = "*", features = ["full"] } 的初始依赖(实际 feature 会缩)scripts/bench_io_async_vs_sync.py —— 跑前后性能对比reviews/r3-<module>.md 模板 —— 记录并发改造 + 基准数字实战里也可能完全不需要 async(某些小脚本同步更快)。这里只是一个可能的审查路线。
**本 skill 必须在 R0 / R1 / R2 均完成之后启动。**必须同时满足:
reviews/r0-<module>-signature.md(R0 通过)reviews/r1-<module>.md(R1 通过)reviews/r2-<module>.md(R2 通过)manifest/modules.yaml 中目标模块状态 ≥ verified若任一未满足,本 skill 直接拒绝启动。
同步 IO ↔ 等待 ↔ 等待 ↔ 等待
Python 版本通常是串行同步的。迁移到 Rust 后,最容易直接获得收益的就是并发与并行能力。
cargo add tokio --features full
cargo add rayon
cargo add reqwest --features json # 若有 HTTP
std::fs::read_to_string → tokio::fs::read_to_stringreqwest::blocking → reqwest asyncsqlx,直接启用其 async runtime;若使用自建同步驱动,本阶段先标为 TODO(避免大范围驱动改动)futures::join_all! / rayon::par_iter()main 函数改为 #[tokio::main] async fn main()(或保留同步壳,业务函数全部 async fn)runtime.block_on(...) 托管异步逻辑;不允许在 tokio runtime 内部再次 block_on 当前 runtime(会死锁)Semaphore 限制并发rayontrace_id,日志仍然可串联Vec<String> 改到 Stream<Item=String>)Mutex/RwLock 的复杂嵌套(那是 R5 要重新审视的)本轮结束前至少跑一份基准:
cargo build --release + 跑一遍 tests/bench/<module>.py,得到基准耗时reviews/r3-<module>.md 中给出理由(例如“为了稳定性放弃 5% 性能”)cargo build、cargo test 通过cargo clippy 无严重 warningreviews/r3-<module>.md