• 【Rust日报】2022-11-01 async-backtrace 发布


    async-backtrace 发布

    tokio 官方团队近日发布了 async-backtrace 的初个版本,旨在让开发者能够高效地追踪应用中异步任务的状态。

    使用步骤如下:

    1. 首先将该 crate 加入到 Cargo.toml 文件中:

    1. [dependencies]
    2. async-backtrace = "0.2"
    1. 使用 #[async_backtrace::framed] 标注一个异步函数可用于追踪,使用 taskdump_tree 以树的形式输出当前所有被追踪的任务状态:

    1. #[tokio::main(flavor = "current_thread")]
    2. async fn main() {
    3. tokio::select! {
    4. // run the following branches in order of their appearance
    5. biased;
    6. // spawn task #1
    7. _ = tokio::spawn(foo()) => { unreachable!() }
    8. // spawn task #2
    9. _ = tokio::spawn(foo()) => { unreachable!() }
    10. // print the running tasks
    11. _ = tokio::spawn(async {}) => {
    12. println!("{}", async_backtrace::taskdump_tree(true));
    13. }
    14. };
    15. }
    16. #[async_backtrace::framed]
    17. async fn foo() {
    18. bar().await;
    19. }
    20. #[async_backtrace::framed]
    21. async fn bar() {
    22. baz().await;
    23. }
    24. #[async_backtrace::framed]
    25. async fn baz() {
    26. std::future::pending::<()>().await
    27. }
    1. 运行上述代码示例,会输出以下内容

    1. ╼ multiple::foo::{{closure}} at backtrace/examples/multiple.rs:22:1
    2. └╼ multiple::bar::{{closure}} at backtrace/examples/multiple.rs:27:1
    3. └╼ multiple::baz::{{closure}} at backtrace/examples/multiple.rs:32:1
    4. ╼ multiple::foo::{{closure}} at backtrace/examples/multiple.rs:22:1
    5. └╼ multiple::bar::{{closure}} at backtrace/examples/multiple.rs:27:1
    6. └╼ multiple::baz::{{closure}} at backtrace/examples/multiple.rs:32:1

    需要注意的是,async-backtrace 才刚刚起步,如果遇到任何问题,欢迎大家在 github issue 上进行反馈

    • 仓库地址: https://github.com/tokio-rs/tokio-metrics

    • 原文链接: https://tokio.rs/blog/2022-10-announcing-async-backtrace

    astro-float:一个任意精度的浮点数库

    作者 stencillogic 近日发布了使用纯 rust 实现的一个任意精度的浮点数库 astro-float,采用了很多广泛使用的算法,例如 Toom-3Schönhage–Strassen 等大数乘法

    此类完全使用 Rust 实现的浮点数运算库还有 ibig、num-bigint,相比于 rug 这类对于 GMP 的绑定库,它们最大的好处是完全用 Rust 实现,不依赖 std,但是在性能上仍有差距。

    更详细的 benchmark 结果可以参考以下文章:

    • bigint benchmark: https://github.com/tczajka/bigint-benchmark-rs

    • astro-float benchmark: https://github.com/stencillogic/bigfloat-bench

    -- From 日报小组 RustPlumber

    社区学习交流平台订阅:

    • Rust.cc 论坛: 支持 rss

    • 微信公众号:Rust 语言中文社区

  • 相关阅读:
    docker的基本使用
    计算几何_三角剖分 POJ3675 望远镜
    最全的 ES 重点内容整理(上)
    Linux常用命令
    C++之6|多态与异常
    少有人走的路--心智成熟的旅程
    浏览器是如何对页面进行渲染的呢?
    leetcode刷题日记:205. Isomorphic Strings(同构字符串)
    python反距离权重(IDW)插值站点到格点
    二十六、rosbag功能包
  • 原文地址:https://blog.csdn.net/u012067469/article/details/127644510